I rarely kill off my characters, but sometimes the only way to achieve a goal is for someone to die.
In the very first Star Wars movie, Obi-Wan deliberately allowed Darth Vader to kill him. He had several reasons for doing this, one of which was to spur Luke and Princess Leia’s Rebel forces to defeat the Dark Side.
Obi-Wan is a complex mentor, arriving on the screen with a past. He has lived and lost and made choices he wished he hadn’t. When he faces Darth Vader in his final showdown, you get the feeling that the old man planned his exit perfectly.
His death was a catalyst, lighting a fire in Luke precisely as he intended.
But there are stupid, gratuitous sacrifices that don’t advance the plot.
David Harth of cbr.com gives us this example of a meaningless sacrifice:
Batman was captured by Darkseid’s forces in Final Crisis and played a pivotal role in the final battle against the God of Evil. For his troubles, he was hit with the Omega Sanction and sent back in time. This was all part of Darkseid’s plan, as Batman would move forward through time, chased by the demon Barbatos, building up Omega radiation. If everything had gone as planned, his arrival in the present would have destroyed everything.
Batman put himself in this position, making a “heroic” sacrifice but he didn’t have to do this at all. He could have given the Radion bullet to one of the Flashes who were also fighting Darkseid at the time and gone and done anything else. 
I suggest you don’t resort to killing off characters because you can’t think of what to do next. In any story, the death of a character must have meaning.
The character arc of the sacrificial lamb has to be thought out in advance, or there is no real reason for their sacrifice other than the need to wring tears from the reader/viewer.
If shock value is what your stories are about, then that may be your purpose.
However, we spend a lot of time and energy creating characters. Why throw them away for nothing?
We form our characters out of Action and Reaction. This chemistry happens on multiple levels.
First, it occurs within the story as the characters interact with each other. At the same time, the chemistry happens within the reader who is immersed and living the story. The reader begins to consider the characters as friends.
For this reason, every sacrifice our characters make must have meaning and must advance the plot, or you have wasted the reader’s precious time.
Good characterization offers me hints of an individual’s speech habits, history, and personal style. It will show me a person with values or sometimes without boundaries. There are things they will or will not do. They have secrets they believe no one knows, secrets they will deny to the grave.
In the books I love and refer back to, great characters dominate. They behave and respond to the inciting incident naturally, in a way that makes me say, “Yes, this is exactly how they would react.” As each subsequent event unfolds, they continue to behave as individuals. No one acts out of character.
Our task is to ensure that each of our characters’ individual stories intersects seamlessly. To do that, motivations must be clearly defined.
- You must know how the character thinks and reacts as an individual.
- What need drives them?
- What lengths will they go to in the effort to achieve their goal?
- Conversely, what will they NOT do? What are their moral boundaries, and what is out of character for them?
Now that you know these things about your character, ask yourself what would inspire this person to sacrifice themselves for others? We know the obstacles our characters face. The choices they make in those situations are the story. Write nothing that seems out of character!
In literary terms, agency is the power of an individual character to act independently, to choose their own path.
When we give the protagonist/antagonist agency, we allow them to make their own free choices. They will sometimes take the narrative in new directions, surprising even you, the author.
Mortally wounded, the antagonist, Khan, activates a “rebirth” weapon called Genesis, which will reorganize all matter in the nebula, including Enterprise. Though Kirk’s crew detects the activation and attempts to move out of range, they will not be able to escape the nebula in time without the ship’s inoperable warp drive. Spock goes to restore warp power in the engine room, which is flooded with radiation. When McCoy tries to prevent Spock’s entry, Spock incapacitates him with a Vulcan nerve pinch and performs a mind meld, telling him to “remember.” Spock repairs the warp drive, and Enterprise escapes the explosion, which forms a new planet. Before dying of radiation poisoning, Spock urges Kirk not to grieve, as his decision to sacrifice himself to save the ship’s crew was a logical one. An epilogue shows Spock’s space burial and reveals that his coffin is on the surface of the Genesis planet, foreshadowing the events of Star Trek III: The Search for Spock. 
Spock explains his decision by saying, “Logic clearly dictates that the needs of the many outweigh the needs of the few.”
Captain Kirk answers, “Or the one.”
When they have unique personalities, it becomes easy to give our characters an active role in choosing their fate. When I am first writing any story, allowing my characters agency is difficult to do. At this point in the first draft of my manuscripts, the motives of my protagonist haven’t quite come into focus for me.
I tend to allow a character’s choices to push their personal growth, so I create a personnel file that is updated as they evolve. I make each character known to me as an individual, down to their taste in clothing.
And yet, they harbor secrets to the end, things that surprise and shock me.
Within the plot outline, the individuality of the characters drives the story. I try to portray them as truthfully as possible because, to me, they are real.
You, as the author, must understand what drives and motivates even the walk-on, disposable characters. Are they “a red-shirt,” that iconic Star Trek symbol of the throw-away character? Why should we care if they die? Your job is to make us care.
When a character has history, has agency, and chooses to sacrifice themselves as Obi-Wan did for Luke or Spock did for the crew of the Enterprise, you see their decision is not out of character.
Their death raises the emotional stakes for both the protagonist and the reader, making a complex, memorable novel.
Credits and Attributions:
10 DC Characters Who Sacrificed Themselves For Nothing, by David Harth 10 DC Characters Who Sacrificed Themselves For Nothing | CBR published February 18, 2021 Copyright © 2021 www.cbr.com (Accessed April 18, 2021).
 Wikipedia contributors, “Star Trek II: The Wrath of Khan,” Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Star_Trek_II:_The_Wrath_of_Khan&oldid=1015970109 (accessed April 18, 2021).