In the 5e times, it rarely happens- mostly with player consent. I guess there is a couple moving parts to the logic. As the DM, you want the players to take the game somewhat seriously and death to mean something and be 'on the table' most of the time. You also want to payers to enjoy the game and be heroic with their PCs, which may lead to death. I'm kind of meh on the difference between having a player roll up a new PC that is the level of the party and for me to find a way to introduce the new PC. Or, for me to find a way to bring back the dead PC.
The PCs are in the Dungeon of Death and a PC dies. I may likely ask the player what he wants. I can make up a temple room dedicated to the PCs god and have a miracle happen, with maybe a favor owed, or somehow have a new PC wander into the dungeon and be found if he was captured, or show up to aid the PCs in a battle and just join the group. Either option pushed believability a bit. I never liked to have the player sit for the night while the others finish the dungeon and can travel back to town.
Yeah, in contrast to a lot of DM's I know, I feel player death is to be avoided just because it can bring the night's adventure to a screeching halt. Even if they have a backup character, you have to figure out how to drop them in (it's rare that the PC's have more than one NPC follower because tracking all those bodies in combat gets tough for me).
This is why I tend not to use time sensitive missions. You have 5 encounters lined up for the session and they have to save the princess? Bad luck in fight 3 kills the Cleric, and not even a short rest will get the party to high enough hit points to have a prayer of winning fight 5.
I could remove numbers from fight 5, but now I have to figure out what to do with the Cleric player, and the other players are demoralized and thoroughly beaten.
And I feel like I did something wrong because nobody looks like they're having any fun.
It's the same reason I don't overuse effects that take someone out of the fight. "Wow, it'd be great if I could play instead of being Held by that shaman!"
Not a great feeling, and the instant someone starts looking at their phone, you know you've lost them. That having been said, I roll in the open and don't fudge things.
Ran with too many DM's back in the day who would "just happen to crit" or consistently make saves from behind their screen...or the dreaded "how many hit points do you have left?".
Give it to me straight, man. It might suck, but I can take it as long as I feel like I had a chance. Or if I didn't have a chance, at least telegraph that in advance!