Dungeon generation
Related terms: BSP, binary space partitioning, rooms and corridors, random walk
A classic recipe uses binary space partitioning. Take the whole map as one rectangle and split it in two. Split each half again, and repeat. Put a room inside every final piece. Then join sibling pieces with corridors, working back up the tree.
Rooms can never overlap and every room is reachable. Other recipes: a random walk that digs as it wanders, cellular automata for caves, or hand-made rooms stitched together at random.