Storyline-Related Deaths - There are some instances where the death of a character fits with plot, character, and setting. For instance, if a given character has strong ties to other characters on the show, and his or her absence couldn't easily be explained away. The best example that comes to mind from my (very) limited scope is Mark Sloan on Grey's Anatomy. After having been established as wanting a child for several seasons, it would have been an abrupt about-face if Mark left the hospital and his family (including daughter Sofia and bffs Derek and Callie). While Shonda Rhimes has been known for killing off characters in unnecessarily violent ways (George was hit by a bus and was rendered unrecognizable to his co-workers, while Lexie died in a plane crash and was eventually eaten by wild animals), killing Mark, who actually had a pretty nice send-off by Grey's Anatomy standards, seemed fitting. Additionally, the plane crash (and Mark's and Lexie's deaths as well as Arizona's injuries) ended up providing the impetus for the following season (which wasn't that great, but at least it served a purpose).
Another, and perhaps more controversial, instance of this is the death of Henry Blake on M*A*S*H. I have enough self-awareness to know that I would have been one of the many angry fans if I had been around when Blake was killed, but in retrospect, the death seems very fitting. In times of war, there aren't always happy endings, and while the show had its share of death because of its nature and setting, having a main character die helped drive the reality of war home.
Actor-Related Deaths - While storyline-related deaths allow for the creators and show runners to work towards achieving some sort of creative vision, actor-related deaths come about as a necessity. Whether it is Coach on Cheers or Finn on Glee, killing off a character after the actor has passed away is usually the right thing to do. Not only does it give the character some closure, it also shows respect to the actor and the audience. In the case of Finn, not only was the character a central one to the show (the Ryan Murphy has mentioned numerous times that his vision for the ending of the show always involved Finn) but Cory Monteith's death received so much attention that having the character fade away into the ether would have been not just impossible but insulting.
Are there other reasons or scenarios where killing off a beloved character makes sense? Please chime in below!