(Human) Nature Red in Tooth and Claw
The ancients took it for granted that the fate of nations was to fight for supremacy and crush and exterminate others. In the wake of the World Wars of the Twentieth Century, and under the shadow of thermonuclear extinction, attempts were made to introduce morality into relations between nations and ban wars. Needless to say, it hasn't happened.
The industrial revolution and capitalism temporarily allowed much of the world to grow faster than population, leading some naive persons to believe that Malthus and Darwin might have been repealed - but they haven't. The precipitous decline in birth rates in wealthy countries has allowed many of them to create societies in which almost everyone can have a decent standard of living, but that has also had the effect of making them a nearly irresistible draw for the rest of the world.
So why are those other countries so poor? Of course there are lots of reasons: a history of exploitation, bad governance, corruption, unsound economics, and societies poorly organized for the modern world, to name a few. One almost universal problem, though, is rapid population growth. Having lots of children not only removes women (half the population) from the workforce, but it consumes any economic surpluses that might be generated.
The citizens of the world's wealthy societies are understandably reluctant to let in immigrants that they fear will suck up tax dollars, not contribute much to the economy, and disrupt the delicate social balances evolved over generations in their societies. This is probably especially true in traditionally homogeneous societies, and of course even more so when a tiny minority of immigrants express their dissatisfaction in violence and terror.
Fundamentally though, countries and their citizens need to find their own ways to prosperity. The world has a number of institutions that try, or supposedly try, to help them, but their track record is not great. In many cases, I think, the fundamental social institutions of the countries are a major impediment, especially to birth control and the education of women. There are many encouraging signs, especially the decline in birth rate and increase in the education of women in the Arab world, but there are also plenty of disasters.