>think this implies this has not always been the case,
This was the case at least through most of the 20th century. Even in the 50s and 60s when "white flight" was cleaning out the predominantly ethnic urban neighborhoods those people were moving to suburbs where they had a lot in common with most of the people there and the people left in the city had a lot in common with each other.
>People came to America partially to avoid religious persecution
It's worth noting that a lot of those groups were being persecuted for being too hard-line and once in the new world they formed their own little groups and kicked out or hanged anyone who didn't agree perfectly with them. While I think we'd all be better off had certain ships sank, members of fundamentalist cults tend to get to know each other, especially when they're trying to not starve and not get scalped by the natives they started a war with.
>And of course, slaves were also brought to America and a whole field of pseudoscience was created to explore how black people deserved their enslavement.
Shared adversity is arguably the best way to bring people together. Now, before anyone misrepresents me as saying slaves anywhere at any time had it good, I'm not. I'm just saying that chronic loneliness was not a problem they had.
To conclude, having stuff in common brings people together and because of the way society tended to work in the past race, religion, nationality, nation, and other things we pretend don't matter today were strong indicators as to how much you had in common with someone and commonality tends to lead to meaningful interaction and/or friendship which solves loneliness.