An episode of "Ken and Robin Talk about Stuff"
from this past October had a segment about what evil deities get out of building all those dungeons full of monsters. They spin some wonderful theories to help justify the ubiquitousness of dungeon crawls in D&D-style games. The short answer is: They're crucibles for evolving better monsters, and wandering parties of adventurers makes the supreme environmental stressor to drive that evolution.