Building a Realistic Dungeon

I first would consider what sort of adventures my players enjoy, and which sort I enjoy DMing. Role play or roll play? Underground or surface? City?

Then I'd consider what flows with where the characters are and what they're doing. If they are in a desert, I'm not going to create a frost giant dungeon.

Then consider the level, classes, and races of your party. If they are 1st level, don't use mind flayers everywhere. If they are all wizards, don't lock them in rooms with iron golems. If they are all elves, tell them to go watch Two Towers again instead. Just kidding.

Flip through the monster manual and list 6-10 monsters that "fit" your concept. Don't forget the PC races. If it were a tomb, I might have several sorts of undead, rats, a construct, and some vermin. I include an ally or semi-ally about half the time somewhere, too.

Now...why does the party want to go there? Rumors of treasure? This works, but it's somewhat trite and lame as a sole motivator, and you are then compelled to give out a lot of treasure (not every time, sometimes rumors are wrong). A given magic item? A substance they need, or a site they need to go to? An enemy to defeat? Investigation? Prisoners to free, or free beings to capture? Figure out how the motivator relates to the monsters.

Then I'd consider what the "boss" of the dungeon is. Is it an Orc lair? I'd design the Orc-king and appropriate other unique characters like his bodyguards, shaman, Ogre guard, etc. Then round out with enough orcs and a few of the other monsters to provide an appropriate size challenge.

Then design the map. If the boss monster(s) built it, and aren't INT 5, then it will be designed for defensibility and utility. Otherwise, they will adapt it and adapt to it. Consider what everything eats and drinks, and where it sleeps. How does it do these things in safety? Where does its waste go? How did it get there? Why did it stay?

Always think about what each room was originally for in an "inhabited" or formerly inhabited dungeon. If it's natural caves, remember that caves are made by either flowing water w/ carbonic acid in it (from CO2), volcanically active areas in contact w/ water (sulfuric acid) or lava action (sure, ocean action too, but that's not normally a dungeon setting...although it could be).

Put your monsters in. Wherever it would make sense for the builder to put a trap, put one (but keep in mind that it could have been sprung and no longer endanger the party)

I like to make sure to have at least one encounter the party can beat without fighting, and often one they can't beat with fighting. Others may want more of these. I don't suggest less.

Plant the seeds of the next adventure in the current one.

Decide how much treasure you want the party to get, roughly. Depending on how likely it is for the party to see every encounter, put that much or more in the dungeon, as makes sense based on the original purpose of the dungeon, the current use of it, and the nature of the inhabitants. In an Orc fort, most of the magic will be on the king and his court, and most of the gold will be locked up safe in a central location, often PAST where the king will most likely encounter the party.

Decide which encounters you think are the easiest and the hardest. Playtest them to ensure you've got ELs where you want them. If you're using a monster that's new to you, or an encounter where the monsters have a situational advantage/disadvantage, playtest this, too.

Then, game on!