Towns and cities have a long history, although opinions vary on whether any particular ancient settlement can be considered a city. Cities formed as a result of geographically centralized trade, benefiting the members living in close proximity to others and facilitating interactions including, but not limited to, economics.
These interactions generate both positive and negative externalities between others' actions. Benefits include reduced transport costs, exchange of ideas, sharing of natural resources, large local markets, and later in their development, amenities such as running water and sewage disposal. Possible costs would include higher rate of crime, higher mortality rates, higher cost of living, worse pollution, traffic and high commuting times. Cities grow when the benefits of proximity between people and firms are higher than the cost.