Don't build Stories. Build Trees.
"For important story reasons this NPC needs to die" means you are building a story. A story that you, as a DM, wrote.
But a good TTRPG story isn't a story the DM wrote. It is a story that the DM and players created out of gameplay.
Some DMs improvise nearly everything - but you want to create a story and have an idea of where things are going. That is ok! But instead of a story, I suggest you build a Tree of Stories.
In a story, you have A following B following C. But in a story tree, you have A or B following C. Anything of importance -- an NPC dying, a battle being won, a city being overrun, whatever -- should have an alternative path.
This will fundamentally limit how far out you can write your story tree, because the number of branches grows exponentially with distance.
An Example
Here is a linear story:
- PCs are recruited to save the lost prince
- Old lady tells PCs fortunes, gives cryptic advice (each PC gets a d20 they can use later on to replace a roll)
- PCs defeat goblins who have lost prince captured
- Prince is killed during escape
- Queen goes mad with grief, cursing the kingdom
- Old lady offers path to save kingdom
- PCs cure curse
Now, we'll build a tree
- PCs are offered to save the prince
2a. PCs accept, go on adventure. PCs pass Old Lady offering to tell their fortune.
2b. PCs reject, are banished from kingdom. PCs pass Old Lady offering to tell their fortune.
3a. PCs get fortune told. Cryptic. d20 rolled, they can use it later.
3b. Old Lady curses (Cryptic) PCs and disappears. d20 rolled, can be applied later.
4a. PCs fight goblins to save Prince.
4b. PCs fight cursed minions of kingdom.
5a. Prince dies in escape.
5b. Prince survives escape.
5c. Prince rally's goblins against curse.
5d. Cursed Prince rally's goblins against world.
6a. Queen goes mad with grief, cursing kingdom.
6b. Queen sacrifices Prince to gain power, becomes Lich
6c. Prince slays Queen, claims her power.
6d. Prince fights Queen, is slain.
6e. Prince claims Queen's source of power, flees.
6f. PCs kill Prince and Queen, claim source of power.
7a. New Dark Lord arises. All worship them, and despair.
7b. Old Lady reappears, offers solution to curse
7c. Players roll new characters, opposing their old ones
7d. Opposing cursed monarchs attempt to woo PCs to their side
7e. Greater problem from outside arises, making the curse seem to be worth the price
By the time I hit 7 steps away from the original story, things could have gone in very different direction. The ideas I'm sketching out can just be to ensure I have some idea where the story could go.
I can create these brief story nodes, and sketch rough lines between them as possible paths the story can go in. Sometimes things would loop back to an "earlier generation" situation, and that is ok.
The core part of the tree isn't that it is anywhere close to complete, it is that there is some depth to every choice, and everything is a branch. I don't decide if the prince dies on the way back from rescue at the goblins! I leave both possibilities open, and ensure they are both interesting.
This means I can set up the fight so that everything tries to kill the Prince; I don't have to pull punches, because both branches of the story are roughly equally as interesting.
Include foreshadowing
Now, one thing that a linear story can do is foreshadow. But you can do the same with a tree - the trick is, foreshadowing should be vague. You can foreshadow any node that is possibly in the story's future. You can keep track of your foreshadows and recycle them with new nodes as the opportunity arises.
So that Old Lady can say "two crowns, one chair, a rose with a bloody thorn" as part of her prophesy, that could be forshadowing for the battle between the Prince and Queen, the external threat that makes the existing curse seem trivial, the PCs rising up against the monarch, or a bunch of other stuff.
Or the Queen could have a stuffed copy of the prince she fawns over but also yells at. What exactly that is foreshadowing is quite flexible.
When you make the foreshadowing happen you should have at least 1 node in mind, but you should also keep the foreshadowing noted and if not fulfilled, when you need a new story node planned you can pull it out and use it as inspiration.
A good D&D campaign should surprise the DM
Sure, we all have an epic story we want to tell. But keep that for a novel! The epic story of a TTRPG should be told in the clash of chance and chaos between the PCs and the DM, not planned out before hand.