This looks like it has what you are looking for:
“As far as I can tell, the oldest apartments — multi-family multi-story dwellings — were built more than two millennia ago, in the Roman republic — and they are spookily modern.
“Back then, cities were bounded by walls. Land inside them was valuable. But the workers – shopkeepers, laborers, maids, housekeepers, stevedores – had to live close to their jobs. Roman law – the first zoning of which I am aware – limited building height to the equivalent of fifty feet. So floor space was at a premium. Enter the insulae.
“By the end of the 1st century BC, a growing pressure for land in many larger, overpopulated cities gave rise to the insula, or apartment. The term insula had originally been applied to rectangularly shaped town building plots. 6–8 apartment blocks could occupy one insula, and were usually designed around an open courtyard. However, with most apartment blocks being three stories high, at least, this simply became a light well. Shops usually fronted the streets at ground level.”
I do wonder if ancient cliff dwellings would classify as an even earlier form of apartment. If nothing else, they might have provided the inspiration for apartments.
Personally, I would rather live in a house. I like having my own rules, a little bit of land, not having to listen to my neighbors, and not having to worry about being too loud for them. However, the cost of apartments makes them a good starting point.
@CaptainHarley What do you mean when you say that they were started for transportation?