The time and place were grim. The country’s population had doubled in a century and tillable land for farming was becoming scarce. Then came a three-year cycle of heavy rains and drought that drove many from their land, hungry, to seek new economic opportunities abroad.

Faced with such hardship, 60,000 people fled during these three years to the US. Many more, in a familiar pattern, would follow those first migrants in the years to come to the communities they founded.

If this story sounds utterly modern in its familiarity, it isn’t.

Because the country described above is not Haiti or El Salvador or an African nation – places reportedly derided this week as “shitholes” by Donald Trump (who now denies he used precisely these words). Instead, it describes a Scandinavia – or more precisely the Sweden of the mid-1860s – whose migrants would become one of the engines of the American push west, with many settling in the prairies of the midwest. And it was not only poor Swedes who came to America looking for a better future. The reality is that migration to America has long been fuelled by grinding poverty and inequality, and the promise of something better.

Irish immigrants left for broadly similar reasons to the Swedes and other Scandinavians. The 4 million Italians who arrived in America between 1880 and 1924 – half of them in the decade between 1900 and 1910 – were often from the poorest, rural backgrounds. And just as familiar as those waves of migration – and the factors driving them – is the response of nativists like Trump.

For Trump, like the nativist movements that preceded him, only the white and wealthy are attractive as new Americans

The US is a nation built on migration and cheap labour from disadvantaged countries, but each nativist moment in its history has been accompanied by similar rhetoric, words that have treated an impoverished or troubled place of origin as a judgment on those fleeing, rather than seeing them simply as victims of circumstance.

For the Know Nothing movement of the 1850s, and the American Party it briefly spawned – whose views have so much in common with the current anti-Muslim sentiment of Trump’s populist moment – that hostility was aimed at poor Irish Catholic migrants. It feared they would take jobs and move into positions of influence, not least in government, while maintaining allegiance to the pope.

And while the Know Nothings quickly imploded over the question of slavery, they set a template for all the periodic outbreaks of nativism that would follow. The origin of migrants, it would argued again and again by populist politicians, made them inferior. Their arrival threatened jobs and their tendencies were criminal. Their beliefs were inimical to traditional American values.

Twenty years after the Know Nothings, the same sentiment re-emerged as fear of Chinese immigrant labour, gaining enough traction to see the passage in 1882 of the Chinese Exclusion Act severely limiting future immigration and barring Chinese residents from obtaining US citizenship – the first major piece of US anti-immigration legislation. That in turn would be followed by the Immigration Acts of 1921 and 1924 restricting the immigration of European and Asian immigrants.

If Trump’s “shithole” comments are unsurprising it is because he has built a political movement on these kinds of judgments. It was of Mexico, during his the campaign, that he suggested “when [it] sends its people, they’re not sending their best … they’re bringing crime … they’re rapists”.

For Trump, like the American nativist movements that preceded him, only the white and wealthy are attractive as new Americans – like the wealthy Norwegians of today – not the Scandinavians of the 1860s. What he forgets – perhaps more likely doesn’t know – is that America was built by those migrating from what a Trump of that era would have doubtless called “shitholes”.

• Peter Beaumont is a Guardian correspondent