From Liquipedia Starcraft Wiki
The term Sim-City refers to a group of buildings or a part of a player's base, constructed in such a way that they serve more functions than those of the individual buildings; usually for defensive purposes by creating a narrow path that enemy units will have trouble crossing or blocking a pathway entirely. An effective Sim City will expose as little of the surface area of defensive structures (eg. Sunken Colonies, Photon Cannons, Bunkers) as possible. The building placements are generally used to fend off melee units.
Zerg are the race that traditionally use Sim-City building placements the least. With the re-popularization of Mech builds however, they have been forced to protect their natural expansions in the early game from vulture runbys, so Hatcheries, Hydralisk Dens, Evolution Chambers and Sunken Colonies are often used in a Sim-City formation. Against Protoss Sim City is frequently used to help block Zealot attacks and Dark Templars.
The most popular form of Sim-Cities used by Terran players are wall-ins. Usually consisting of a Barracks and Supply Depots, they provide protection to the Terran base while teching to Factory or Starport units. Vs. Protoss, it is also used to prevent Siege Tanks from being destroyed. While walling has its benefits, it might not be used if the Terran decides to use units to hold the entrance to their base (especially in TvT and TvZ), or if they are going for an early aggressive build. Walling also provides a slight economical disadvantage to simply placing the buildings within the base.
Another very common use of building placement occurs in the early game Terran vs Protoss, where the Terran player does not wall but places his Barracks and first Supply Depot in such a way that Marines can pass between them but zealots can not. This way, even though zealots can enter the Terran's main base, they can not get close enough to the marines to hit them, as the marines have an exclusive "escape route." When making this sim-city, it is advantageous to build it as a a type of wall to protect SCVs, and to build your first factory in close proximity as well so that the Zealot cannot snipe the SCV building it.
Terrans also place buildings like Barracks, Engineering Bays, and Supply Depots in strategic positions to protect their siege tanks. This is usually done when pushing vs. Protoss. They can build depots and land the Rax and E-Bay in front of tanks so that Dragoons will shoot the buildings first, and so Zealots cannot charge straight up to the tanks. Additionally, Buildings may be placed at the entrance to expansions to wall-in again and let tanks destroy enemy units that attempt to enter.
In TvZ, sometimes buildings like excess supply depots and production structures are placed 'against the wall' in order to give maximum freedom to M&Ms rushing to catch and surprise mid-game Mutalisks harassers. In this way, it's simply the fact that the buildings are out of the way and allow maximum movement that conveys additional benefit.
When fast-expanding against Zerg, Protoss players always use Sim-Cities to protect their natural expansions by creating a very small entrance that can easily be blocked with Probes or Zealots to prevent Zerglings from running by.
Against Terrans, the most common form of Sim-City used by Protosses is Pylon Walls to make the entrance of the Natural expansion narrow enough to prevent Vultures from coming through, or in the case of a third or fourth expansion, sealing them off completely.