There are five main processes that states juggle when setting policies on immigration, including economic immigrants, refugees, and asylum-seekers.
 Capital accumulation vs. protectionism. Modern capitalism favours the widest possible movement of capital and labour across borders for maximizing profit. In alliance with political forces, however, it can swing towards protectionism. A pro-business party is not necessarily strong enough in its own right; often it allies with conservative and nationalist sentiments in order to get elected.
 National identity rests on popular democracy. The modern state originated in a reaction against dynastic family rule and feudal alliances; we generally refer to this as the rise of democracy, but it also was a move away from internationalism (since dynastic marriages were often across linguistic and cultural borders) and towards nationalism. The replacement of feudalism with a centralized state apparatus moved towards a monopoly of legitimate force upon a bounded territory; and this too built nationalism. Along with internal pacification and policing came border guards, customs, identity checks, and passports. Since the 19th century, states have penetrated their societies with institutions of education, mass media, uniform laws, even sports leagues as well as standardization of language, all driving in the direction of greater homogenization. National identities were built, or intensified, by the territorial state. And modern states (almost all) claim legitimacy based on sovereignty of the people who live there; democracy always has a territorial referent, and democracy reinforces feelings of nationalism.
Nationalism is not necessarily xenophobic, but modern citizens cannot help being aware of distinctions between themselves and outsiders. We can call this populism, perhaps even implying that it is a dangerous form of democracy; but it is nevertheless a result of widespread public participation in politics.
 Internal politics in a democracy is concerned, among other things, with bread-and-butter issues of taxation, welfare expenditures (whether provided by government or by insurance), and employment. Immigration always potentially raises questions about how much it will cost, directly if refugees are given special housing and support, and indirectly in competition for jobs. These issues have different intensities depending on whether the economy is growing or stagnating. People living in different regions where their own economic experience is downwards or upwards have different attitudes towards immigrants.
 Liberal commitment to altruism and diversity. Many NGOs, and swatches of public opinion are dedicated to the plight of refugees and immigrants. Other social movements and ground-swells of opinion see them as potential dangers (future terrorists? revolutionaries?) or as eroders of local lifestyle and shared social identity. It is an under-theorized question in sociology why such movements lean one way or the other. Media news stories of refugees and images of individual victims (especially young children) create sympathy. But this is a time-bound phenomenon, often temporary; large flows of refugees can lead to a counter-reaction; and large numbers drown individual suffering in statistics, making international audiences jaded.
Pro-immigrant or anti-immigrant policies (or some mixture in between) is the resultant of these four vectors of political influence, impinging on state policies.
A rare example of how these four processes interact is Loyal and Quilley (2018) explaining Ireland’s refugee policies over the years: During the early years of the Irish Republic (1920s and 30s), the political focus was on Gaelic nation-building, a reaction against centuries of English domination. Cultural nationalism combined with penurious welfare and job policies, resulting in excluding all but a handful of refugees during the Nazi/World War period. Capitalist openness to capital and labour dominated during the Celtic Tiger period of economic boom, when the magic key was American investment in a low-tax country with entry to EU markets. And a sudden proliferation of NGOs in Ireland since the 1990s, became part of an unexplained ground-swell of altruistic internationalism.
Altruistic movements tend to take themselves as the default setting, the theoretical baseline against which we study other movements. There are plenty of studies of nationalism and anti-immigrant sentiment; but altruistic/internationalist movements need a sociological explanation too. No such theory is offered here, but the Irish case and its historical context points up an important factor—not indigenous to a given state, but operating from without:
 The social construction of international law. The Universal Declaration of Human Rights (1948) and the Geneva Convention on the right to asylum from evil regimes (1951) were established by international treaty. These are perhaps the strongest force favouring refugees, since none of the state-centered and domestic forces listed above are unequivocally pro-refugee, and they often act in a nativist manner. Arguably the proliferation of NGOs is a movement into the moral and conceptual niche created by international treaties. But how to improve our analysis from a recitation of arbitrary historical facts, to a theory that explains when international agreements are made, and what makes them popular? Signatories to international treaties often fail to live up to them, since implementation is left to national states.
Let me suggest some general processes. The big treaties were the result of international conferences, held among the victorious powers at the end of World War I and II, and in the Cold War period leading to the collapse of the Soviet empire. Ostensibly these treaties were created so that the causes of war and forced population movements could be remedied. The diplomats of the Great Powers tended to frame laws on human rights against the regimes they defeated or were currently opposing: genocidal regimes and ideologies, forced labor, atrocities of ethnic cleansing, stifling of political dissent.
But as new regimes and alliances have appeared, the original intent of international law found new targets: condemning atrocities by Nazis and Communists were now shifted to critiques of colonial and post-colonial regimes, and declarations of universal human rights could be aimed at segregation or discrimination by race and religion, or yet further by gender or sexual preference. For this reason, world powers like the U.S. have backed off of agreement or enforcement of international treaties such as those allowing prosecution of soldiers for their behavior abroad. In sum, Great-Power diplomacy is an unreliable basis for laws guaranteeing universal human rights.
This brings us to an unexpected source of moral commitment, the diplomacy of small states. The very fact of being militarily weak, or being outside of the major alliances (the situation of Ireland and the Scandinavian countries) gives an opportunity for international prestige, as a neutral arbiter, taking a fair and altruistic stance above the game of power. Humanitarian activists from the small and unaligned states became prominent in the early years of the United Nations and other international treaty organizations: one thinks of Dag Hammarskjold (an activist UN Secretary General and martyr for international mediation), and Ireland’s Conor Cruise O’Brien, sending blue helmets against insurgents as de-colonization rippled through Africa; more recently, former Irish President Mary Robinson as UN High Commissioner for refugees. Max Weber argued that states enter into wars largely in order to bolster their power-prestige in the international arena; even at an economic cost, they want to be seen as major players in the game. History since 1945 suggests a corollary: small states, without military power, can achieve international prestige by staking out their position as leading internationalists.
The question is: what determines the balance of the various forces pro and con refugees in the many states of the world? Theories that assume they are the arc of history are not necessarily good predictors. Add the causal forces together and we will see.
Steven Loyal and Stephen Quilley. 2018. State Power and Asylum Seekers in Ireland. Palgrave Macmillan.
Sinisa Malesevic. 2019. Grounded Nationalisms. Cambridge Univ. Press.
Michael Mann. 2005. The Dark Side of Democracy. Cambridge Univ. Press.