I was recently reading an older RPG and came to a part about "script immunity". Basically, the PCs aren't supposed to die unless it is necessary for the story being told. It got me thinking about something that has bothered me with D&D for a while now (particularly in 5E). I feel like the PCs aren't supposed to die, and I have heard how several groups now house-rule TPKs turn into captures, or the "it was all a dream" fake-out when PCs die, etc. Many DMs don't like bad luck killing off a PC unless they were doing something foolish (I've been in this position before as DM).
I know D&D is not about "winning" or "losing", but about the adventure, challenge, and story being told. However, lately I feel like a story that is already meant to be "successful" or "won" is not worth the telling. I have no interest in running a game where the players actually expect things to be ok. Where is the excitement if they believe the PCs will be ok--somehow...? Even if you have other goals where the PCs fail--it might not be heroic--but they are still there to try again.