In fact, if you jointly score social mobility & ethnic diversity, the United States looks to come out very close to the top (if not the top). It's probably not a "one size fits all" solution, though social safety nets are obviously a critical part of the equation.
[1] https://en.wikipedia.org/wiki/Global_Social_Mobility_Index
[2] https://en.wikipedia.org/wiki/List_of_countries_ranked_by_et...
It's the legal framework, the laws being actually enforced (low corruption), and just the culture of the lay people who learned to trust each other after centuries of that. Formally Sweden is a kingdom while Nigeria is a democratic republic, but it does not change much.
Sweden has a ~55% marginal tax rate for everything over SEK 309,000 (approx 55k USD).
55k USD isn’t much in most US tech companies.
Nigeria is a poor country which still has a high birth rate. Outside of Africa, almost all countries are past that. Even China and India.
[1] https://borgenproject.org/poverty-in-sweden/