There are some authors who pull off killing a main or side character flawlessly. Some authors have done it numerous times, with some successes and some failures. Others have tried to get it right, but have ended up missing the mark.
That brings up the question: What makes a "successful" death in writing?
Now, before I discuss the types of deaths, and how some have been successful, know that I am talking from my own standpoint. I am one person, one reader, and one writer. My opinions are my own, and mileage may vary. Also, I encourage you to comment on why a death worked for you. Was it a reason different than below?
The Romantic
When the romantic interest of your main character takes a drastic turn for the worst, it needs to be gut-wrenching. The death should be a tear-jerker. As readers, we need to feel the soul-crushing hopelessness of the main character as the thought settles in--forever, without the love of your life. We need the horror, the disbelief, and the pain of the moment, all wrapped up into one emotional upheaval. Without it, this death might seem pointless.
The Martyr
This is one of the hardest techniques to pull off for both main and side characters. Rarely do main characters die in books, and it's because we, as readers, have such an emotional connection to them that we cannot imagine a life where they no longer exist. If you decide to make a character a sacrifice, you need to make us believe it. It's the hardest challenge, but if you can pull it off, your story will likely stay with the reader forever.
On the emotional side, the reader needs to feel disbelief. That feeling needs to become acceptance because the story was so beautiful it couldn't have happened any other way, or anger for the person responsible for the MC/side character's death. Oftentimes, readers need to blame someone. If you take away the beauty and the ability to blame a character, your readers will turn to the next person on their list--the author. I've seen this happen. If you can't pull off a martyr, your readers may turn against you. Tread carefully - it's a fine line between success and failure.
The Friend or Family
Arguably, the friend/family is the most versatile character when it comes to death. It could be a sudden, unforeseen accident; an elongated illness; a brutal murder; or a suicide. All of these need to contain disbelief, yearning for answers, and even anger. Most stories that have done this successfully eventually carry some hope, like the main character's ability to carry on against all odds. Sometimes, the death of a friend or family member will begin a trial, where the MC will be tested time and time again. Grieving is encouraged, but they need enough resolve to keep going, even if it's just going through the motions.
The Villain
Should all deaths of enemies create instant relief? Not necessarily. If your "evil" character is well-rounded, there should be some redeeming quality to him or her, even if it’s just superficial. The death of your villain should be satisfying, but not overly so. The world is not black and white, and your reader should see both sides to your villain. And remember - death does not always equal justice. Just because X is dead doesn't mean everything is magically okay. To some extent, because X existed in the first place, some things will never be okay.
What it boils down to
There are obviously more categories out there. It boils down to the author needing to make the reader believe it. Forcing a character's death for controversy won't make readers connect with the demise of their beloved character. If you miss the emotional mark, your story might be less successful.
I encourage you, as a reader, writer, or movie lover, to comment on why a certain character's death worked for you. You can be vague or mention specifics, but remember to mark any spoilers, please!