There were a couple of major reasons that come to mind. First, immigrants tended to follow family or friends that went before them. They might know a cousin that settled in a certain area, so they’d go there too. When this repeated on a large scale, it led to certain groups being attracted to areas of the country that already had communities that would be familiar to them. It’s similar to how a lot of Chinese immigrants to San Francisco would settle in Chinatown. They often knew people that had already moved there, the community was largely familiar to them, etc.
In more practical terms, money explains quite a bit of it. The quality of life was generally considered better in the Midwest. Settlers could have their own land, plant crops, build larger houses, enjoy the open space, earn money from farming, etc. However, it took money to get to the Midwest, acquire land, and build a home. Immigrants from Germany and Scandinavian countries usually had at least some money; at a bare minimum, they were usually wealthier than Italian, Irish and Polish immigrants.
Immigrants without any resources usually stayed in the cities in which they arrived (Boston, NY, etc). Large ethnic communities formed where they could perhaps leverage a family member or friend to find a job. These jobs let them get by, but they usually weren’t getting rich. As a result, they generally stayed in the cities and lived their lives there.
I hope this answers your question.