Why Do Cities Exist?

You might have lived in a city your whole life, or moved to a city from somewhere smaller, or visited a bunch of cities, without ever pondering this question: why on Earth do these monstrous places exist at all?

These sort of questions can be considered on a philosophical scale, or in terms of social sciences, or through a cultural lens... but eventually, like so many topics, it eventually gets eaten up by the monster of Economics.

The question really boils down to: How are cities economically viable? Are they a drag on the economy or a benefit? How do cities make money? How to they add value?

You can see how a farm fits into the economy. You can see how trucks fit into the economy. You can see how a factory (or a factory town) fits into the economy.

But what does a city produce? It produces, crime, hipsters, pollution... it must produce something else to offset the negatives.