Romans grew gardens inside their homes. The Roman name for a courtyard is peristylium. The peristylium was a key area in Roman homes. Courtyards were a central feature of many ancient homes. Homes today often have patios. An enclosed patio is a courtyard. A courtyard provides a pleasant place to relax and entertain guests.
A party of adventurers exploring a ruin of a city or town will likely find the remains of homes with courtyards. Courtyards can exist in underground dwellings. Dwarves can build courtyards and bring in sunlight via mirrors or crystals.
Courtyards tend to be larger areas. Courtyards provide a dungeon master the opportunity to be creative. Everything in the courtyard can be a point of interest for the party.
Courtyards are usually tiled or paved. The party enters the dusty courtyard. They notice a pattern in the paving stones not covered by dust and dirty. Sweeping away the dirty the party finds a mosaic of a large blue monster holding a cookie with the caption "Me eat cookie!"
The floor of the courtyard provides an opportunity to continue the story of the campaign. The floor could give hints at what lie in the catacombs below or show the prowess of the original owner. A classic example is the mosaic in Pompeii of a dog with the caption "Cave Canem!" which means, "Beware of dog!"
To make a courtyard interesting provide the players with the opportunity for discovery and interaction. For example, cover part of the mosaic with dirt or make the mosaic incomplete. Impress on the party how lifelike the creature appears in the mosaic; however, someone pried the pieces with the eyes and mouth out. Does the party put the pieces back? If so, is there any kind of reaction?
Ceramic tiles can act as trigger mechanism. Traps are obvious. What is not as obvious are sounds. For example, when a character steps on a specific ceramic tile it triggers a small hammer to strike a tuned metal bar making a sound. The floor is a form a xylophone or metallophone. Dancing across the floor will play music. The party could dig up the floor, follow the wires or strings, and find the xylophone.
Plants can decorate a patio or courtyard. Plants could provide a variety of alchemic ingredients. In a fantasy world, plants could do more than just look pretty. A courtyard would be a good place for an Audrey II plant from the movie "Little Shop of Horrors". A large tree in the courtyard could be the home of a Dryad. Alternatively, the plants could be a non-player character giving a vegetables view of the party. A plant non-player character may consider vegetarians horrible monsters.
A reflecting pool could function as a magical mirror. Looking into the reflecting pool could allow viewing other places. Magical fountains offer other diversions. For example, positioning a potion to reflect in the reflecting pool causes the fountain to spray out that potion providing a limitless supply of potions (or not).
Statues commonly adorn ancient courtyards. Some statues could be previous adventurers who did something wrong with the pool and ended up drinking a potion that turns the drinking into stone.
The key is to make each area interesting to the party. The area does not need to be harmful or helpful. The party needs to have a tale to tell when they get back home.