In the late 1800s, cities grew mainly through immigration. As can be seen in the link below, there were huge numbers of immigrants in American cities by this time period. Foreign-born people made up 33% of the population of large cities by 1870. Many important cities like Chicago and New York had populations that were over 40% immigrant.
Typically, these immigrants stayed in the cities in large part because that was where economic opportunity was. This was a time when the US was becoming more and more industrialized and there was plenty of work in cities for people without any particular skills. Because there were so many (albeit hard, low-paying, and menial) jobs in the cities, immigrants ended up staying in those cities.
Of course, this was not all good. The influx of immigrants (many or most of them poor) caused all sorts of problems in cities. Chief among these were things like unsafe housing, crime (including organized crime), and corruption in city governments.