As a gm, I'm not out to kill characters. I try to present the obstacles, describe the setting accurately and vividly, and make sure the rules are applied fairly to all (pc and npc alike).
That said, I'm not out to keep anyone alive either.
Sometimes characters die because they do something stupid, and sometimes its because they were just unlucky. Chance is always a factor. As a player, I don't want a gm maliciously trying to kill me, or benevolently trying to keep me alive. As long as the gm is fair, I'm happy with the consequences.
Part of the game is gambling. Instead of betting money you're betting the time you put into a character and the desire to keep playing it. But if you can't lose, then it’s no fun winning.
I've had players who thought characters should only die "if they do something stupid", or think that if they can't solve the mystery, the gm will fudge it so they make it to the end combat. All I can say is, I don't get it.
The part about the "do something stupid" that I have a problem with is that, who's to say whats stupid? As a gm, I pretty much get the final word on the subject, but I am aware that the authority to declare an action stupid doesn't have with it any special power to be correct.
Sometimes, no matter how brilliant a group of players you have, you will be staring over the screen wondering who these morons are and how they got into your house. The thing I had to realize is, as a gm, my judgement of what was the right or wrong thing to do was based around having perfect information. I had read the module or designed the adventure, so I knew the repercussions of the pcs actions. Pc's don't have that benefit. They make their decisions based around the information they have, which is the information that I give them. If they're tackling a scenario in an asinine manner, then there exists the possibility that instead of them being morons, I presented it poorly. (Sometimes they're just morons. It can go either way.)
Further, just because something is obvious to me doesn't mean it’s obvious to anyone else, or even especially right. What if the gm's idea on how to tackle a situation is moronic? Are any of us infallible? (It’s a rhetorical question.) I've played in games where the gm decided on the correct course of action and would punish the party for not doing it (and not consciously, just if you deviated from what he thought was 'right', it was skewed against you). All I can say is, for a group of players, it’s not the most fun way in the world to spend a Thursday night.
I prefer to design open ended scenarios. I try to know what capabilities and motivations the npcs have, and come up with a few ways they and the pcs are likely to meet. But I find It’s fairly useless to try and pick what path the pcs will take (except in the broadest sense), and all but impossible to say how it will turn out. Letting the situations play out in unexpected ways is where a lot of my enjoyment of the game comes from.