Sayfullo Saipov did not arrive in the United States alone. In 2009, he was one of 3,284 lucky residents of Uzbekistan to win the green-card lottery. That same year, the lottery granted green cards to—among others—2,894 Albanians, 590 Australians, 1,154 Bulgarians, 4,307 Kenyans, and 2,331 Turks; for a total of 50,000 admissions.  

Good and bad qualities are randomly distributed in the human population, and randomly is how the diversity lottery distributes its rewards. So it should not be very surprising that one member of the class of ’09 proved to be a mass-murdering terrorist. The lottery imposes no requirements of skill, not even knowledge of English. Convicted criminals are excluded, as are persons affiliated with known terrorist groups. There is a basic health requirement. Beyond that, the system is—as it says right in the title—a lottery, open to anybody with a working Internet connection and $30 for the entry fee.

You might wonder: Why do we do this? Why would the United States forswear the right to choose the people it admits, to assess them for what they can contribute to the welfare of the community to which they seek entry?

The answer lies in history, not reason.

The diversity lottery originated as an attempt to offset the unintended consequences of immigration changes since 1965. The immigration law adopted that year unwittingly—indeed, contrary to the repeated insistences of its authors—reopened the United States to mass immigration. That law gave first priority to the relatives of the most recent immigrants: not only spouses, but also parents, siblings, and then those siblings’ children, including adult children. As a result, the 1965 law tended to bunch the sources of U.S. immigration ever more intensely in a comparative handful of source countries.

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.

Trump’s huge personal unpopularity has this perverse effect: When he endorses something (like Republican tax reform) it loses support; when he attacks something (like transgender soldiers), it rises. But not even Donald Trump can be wrong all the time. By reacting so strongly to him, the American political system forfeits its ability to think for itself. The diversity lottery epitomizes how far U.S. immigration policies have drifted from any purpose or sense.

As Sayfullo Saipov reminds us, when you admit immigrants without regard to suitability, you receive immigrants without regard to suitability. When you don’t care what you take, you will get what you don’t want. Just this one time, let American policy react to facts and logic, rather than Trump’s ill-considered twitterings.