This is based on the UK experience, but I think some of this will also apply in the US.
Why do right wing politicians push an anti-immigration platform? The obvious answer is that immigration is an important concern to their voters, and that is certainly correct. However I think there is an additional factor, which is illustrated by this interesting graphic from a recent Financial Times piece by Sebastian Payne.
Look at the right hand panel, based I believe on British Election Study data. This is the two dimensional way of representing political views I have discussed before. What we call the vertical axis can vary (culture, identity): I prefer the labels ‘social conservatives’ and ‘social liberals’. Conservative voters tend to be right wing and socially conservative. But Labour voters, while clearly left wing, include an important segment that are also socially conservative. As a result, if right wing politicians can make elections about issues that are important to social conservatives (law and order, immigration, race and abortion in the US) they have a chance of picking off Labour voters that would otherwise vote for a left wing candidate.
Immigration is particularly attractive to right wing politicians for a reason I explored in a recent post. There is a common misperception that immigration brings economic bads like lower wages and reduced access to public services. Right wing politicians therefore have a chance of persuading Labour voters to substitute their economic concerns away from supporting a left wing candidate into supporting an anti-immigration candidate on economic grounds.
The standard story perpetuated by the broadcast media in the UK is that heightened concern among voters about immigration over the last decade is a response to high numbers. However it was more than that. The Shifting Ground study has an interesting chart shown below.
The blue line is the importance that voters attach to the issue of immigration. The grey line are the number of migrants coming into the UK. The black line are the number of news stories about immigration in the print media. (See here for the source.) The standard story suggests the blue line (importance) responds, in the first instance with a few years lag, to the grey line (immigration numbers), with the black line (news stories) reflecting people’s concerns with no lag at all. But it is obvious that you can tell a very different story: people’s perceptions about the importance of immigration reflect what they read in the press.
This different story, where the press leads opinion, makers much more sense. Why the long lag between the increase in immigration in the late 90s and public attitudes about the importance of immigration? As is well known, public concern about immigration tends to be greatest in areas where there are least migrants. In a poll commissioned by the Sun newspaper in 2007 only 15% said that migrants are causing problems in their own neighbourhood, while 69% said that migrants were not having a strong local impact, either good or bad. There is a nice story Nick Clegg tells on this:
“Years ago, before I became an MP, I was knocking on doors in Chesterfield, Derbyshire – this was at the height of the controversy about asylum seekers being dispersed around the country when Tony Blair was in power. The tabloid newspapers were going nuts about it every day. I remember speaking to a guy leaning on the fence outside his house and saying: “Any chance you’ll vote for the Liberal Democrats?” And he said: “No way.” And I said: “Why not?” And he said: “Because of all these asylum seekers.” And I knew for a fact that not a single asylum seeker had been dispersed to Chesterfield. So I said to him: “Oh, have you seen these asylum seekers in the supermarket or the GP’s surgery?” And he said something to me that has remained with me ever since. He said: “No, I haven’t seen any of them, but I know they’re everywhere.” You can’t dismiss the fear, but how on earth are you supposed to respond to that?”
“new research from the Migration Observatory at Oxford University shows just how pervasive and systematic this hate campaign is. After studying 58,000 articles in every national newspaper in Britain – over 43 million words – researchers found the word most closely associated with 'immigrant' was, you guessed it, 'illegal'. … For tabloids, other words closely associated with 'immigrant' were 'coming', 'stop', 'influx', 'wave', 'housing' and 'sham'.”
A recent report from the same source finds ‘mass’ as the most common way of describing immigration. Claims made about immigration in the tabloids are frequently untrue. They are almost always negative, often extremely negative. This is not a coincidence, or as a means of boosting sales: it is a deliberate editorial policy.
In opposition the Conservatives could do little more than ramp up the salience of the issue among their base and among readers of right wing tabloids. Labour on the whole triangulated in public. Gordon Brown’s famous remark after being challenged over the economic impact of immigration in the 2010 election showed both how Labour viewed anti-immigration arguments and also the problems with their triangulation. Once the Conservatives gained power as part of the Coalition in 2010, immigration as a major problem became official.
Furthermore, arguments linking immigration to economic problems that had nothing to do with immigration also became official, as the Conservatives used immigration as a useful scapegoat both for falling real wages and the impact of austerity on access to public services. This in turn fed back into the print media as a whole: whereas in 2006 many articles defending immigration could be found outside the right wing tabloids, these diminished in number by 2013.
If the right wing tabloids created an anti-immigration atmosphere in parts of the UK, after the Conservative’s ‘less than 100,000 target’ for net immigration it became government policy. Yet, as I argued here, it was - like the tabloids - a policy born in deceit. Every time Theresa May tried to suggest significant economic measures to reduce immigration, a combination of George Osborne and Vince Cable knocked it down for the very good reason that it would damage the economy. Her only choice was to create, literally, a hostile environment for immigrants into the UK.
Although formally the policy is only designed for illegal immigrants, it inevitably turns the anti-immigrant rhetoric of the tabloids into official government policy. Landlords are reluctant to let accomodation to EU immigrants in case their papers are not in order. The same applies to healthcare. I wrote about the bureaucratic cruelty shown to foreign students, and most academics will have similar stories from their own experience. Colin Talbot describes the experiences of EU academics after the Brexit vote. The simple cruelty of this policy does not go unnoticed abroad (for example here and here from Heiner Flassbeck and well worth reading), and the contrast with Germany’s policy towards refugees is stark. 
Brexit was the apotheosis of this policy towards immigration. Although Remain gained a few liberal Conservatives, they lost more left wing social conservatives, as the left hand side of the first figure shows. The right wing tabloids were of course not innocent bystanders in this, but the key point is that they didn’t need to do anything new except ramp up their anti-immigration stories and make sure they always mentioned the EU. The key point of this post is that what happened in the Brexit vote was simply what right wing politicians and newspapers have been trying to do for nearly 20 years: use immigration as a way of preventing socially conservative left wing voters from going with Labour.
 Viewing from abroad you might be forgiven for thinking the British were now an insular, uncaring, rather bigoted nation. Yet when a photograph of the body of a three-year-old refugee washed up on a Turkish beach went viral, the Sun - always quick to see the limits to how far it can distort news - launched an appeal and within two days had raised £350,000 to help other refugees. It was a brief and short-lived moment when natural compassion proved stronger than years of conditioning.