We've come a long way from death in games simply being a punishment to send you back to the beginning and encourage you to push more quarters into the arcade machine, but even today a lot of developers continue to implement dying as an inconvenience that can always be avoided if you're good enough.
It's a sensible approach, all things considered. If you make death inescapable and restrict players from avoiding it, you can drag an experience out and make it frustrating. Though, when most games are built to be unadulterated power fantasies, drawing attention to how fragile characters are would contradict the whole point.
However, there are some releases over the years (often the most morbid ones) that have actually made death a central part of the experience. Rather than throwing it in as an obstacle to overcome, developers have instead purposefully killed players to send a message, whether that's to communicate certain game mechanics or deliver a powerful story moment.
Of course, main characters in games die in cutscenes all the time, but it's a different thing entirely when you're given the illusion of having a fighting chance, only for the hammer to come crashing down, murdering you anyway.