A sensible (though boring) reason for a dungeon to exist: it functions as a dungeon. It was built to hold someone or something. It has good security, traps, guards, and monsters because it's supposed to prevent the person from getting out, and also to prevent outsiders from breaking in and rescuing him. It's usually underground or in some hard-to-reach place because that makes it harder for the person to escape and harder for other people to break in.

So, the question then is, what are you guarding? It could be anything important to the plot. Trapped comrade, trapped enemy that you need to pump for information, trapped demon who's posing as a friend, trapped demon that the cultists are trying to free, fragment of the Lost MacGuffin of Ultimate Explodey that you need to find and destroy, broken Fargate to the plane of Sticky Mess that the mad scientist is trying to reactivate. Anything, really.

Though one idea I had, was a dungeon created as a spiritual test by a group of pacifist clerics. The initiate would go in, and be told to get ready for a spiritual struggle, and that the greatest foe of the world is at the heart of the dungeon. The dungeon is in a timeless plane, and would go on indefinitely, with increasingly more difficult creatures. Anyone who fights and kills the monsters gains illusory XP and treasure for as long as they're in the dungeon. But if they subdue the monsters without killing, the XP and treasure is real. If a character dies fighting a monster, they end up back at the beginning with the Cleric, who tells him to go back and face the challenge again. But if they either turn back or willingly let a monster kill them, they've beaten the dungeon.