This bias strengthened after the Simpson-Mazzoli Act of 1986. That law conferred legal status on some 3 million unauthorized immigrants, almost all of them Mexican. The back-home kinfolk of the 3 million who received amnesty quickly advanced to the front of the immigration queue.

Among the groups most irritated by these changes were Irish Americans. Ireland in the mid-1980s remained a poor and depressed country. Many Irish wished to emigrate to the United States, but found the entrance blocked. Their friends in Congress—then Senator Edward Kennedy, then Representative Chuck Schumer—went to work to create a special Irish preference. The diversity lottery was their solution.

Only … it went into effect in 1995, precisely the year that Ireland at last revved into gear as one of the fastest-growing economies in Europe. Why leave just as the party was getting good?

Instead, the diversity lottery discovered a whole new existence, as the favored way for urban Africans to escape their continent. In fiscal year 2015, 10 percent of the population of the Republic of the Congo applied for the US diversity lottery, 8 percent of the population of Sierra Leone, and 7 percent of the population of Ghana.

There may be some cosmic justice in an affirmative-action program for white people converting itself into a golden ticket for the world’s poorest continent. But what American purpose is served? After President Trump’s outburst on Twitter against the program, many people of goodwill scurried to develop an answer to that question. But as so often with U.S.-immigration policy, these answers are rationalizations after the fact, not arguments before the fact.

The story of American immigration since 1965 is a story of unintended consequences, yielding results that even their authors would have opposed had they foreseen them. It’s the story of a government program, almost all of whose costs are borne by Americans and almost all of whose benefits are collected by people who were not Americans at the time they received the benefit. It’s the story of a program where it’s considered somehow objectionable even to ask the question, “Why?” The program’s existence has become its own justification. The political clout of the program’s beneficiaries has become the all-purpose answer to questions about its merits.

This is true of immigration programs generally, but the truth is underscored most heavily in the diversity lottery. While Canada, Australia, New Zealand, and others choose their immigrants, the United States is content to let immigrants choose America. Other countries integrate immigration into human capital development strategies alongside prenatal-health programs, preschools, and K-12 education. The United States shrugs off the terrible and intensifying deficits of its native-born population—from obesity through drug abuse to gun massacres—and looks to the virtues of immigrants to compensate for the neglect of its own people.