It’s appropriate that the UN special rapporteur devoted to adequate housing has visited encampments in Mexico City, Buenos Aires, Mumbai — and San Francisco, Oakland and Berkeley.

The homeless situation in those cities and others around the country is positively Third World, a blight that shows the persistence of human folly, and misery, despite what we take to be our steady progress to greater enlightenment and prosperity.

San Francisco is a crown jewel of the new economy, and a sink of vagrancy. One of the more compelling pieces of reportage that The New York Times has run recently was on the dirtiest block in San Francisco, the 300 block of Hyde Street, blighted by discarded heroin needles and other filth.

In the 21st century, in the richest country on the planet, you would think that we would have figured out how to live without having to step around human feces. The experience of San Francisco says that, against all expectations, we haven’t — or at least we forgot how.

It used to be a journalistic trope that homelessness spiked whenever a Republican occupied the White House, but it’s more obvious than ever that it is an endemic social problem. Homelessness is roiling the politics of impeccably progressive cities like San Francisco — where tech barons split on a proposal for a new tax to fund homelessness programs — and Seattle.

In an article for the journal National Affairs, Stephen Eide of the Manhattan Institute recounted how we got here over the last 50 years.

Cities wiped out or drastically diminished their skid rows, once a last-ditch housing recourse for men who had hit bottom. As urban renewal and regulations to improve the quality of housing eliminated these down-on-their-luck areas, the people who once lived there decamped to public places.

We “deinstitutionalized” the mentally ill, too often a euphemism for dumping them onto the streets and into jails. About 20 percent to 30 percent of the homeless are mentally ill.

Meanwhile, the number of single-parent families drastically increased. Women only rarely lived on skid row, but poor families headed by single mothers are a large component of the homeless.

Eide notes that in New York City “two-thirds of the homeless population is comprised of families with children, and around 90 percent of those families are headed by single mothers.”

These large-scale trends have been met with a new restrictive legal environment. The Supreme Court in 1972 made it more difficult for city police forces to hustle along vagrants, and subsequent free-speech jurisprudence has made outlawing panhandling tricky. Civil commitment of the mentally ill has become highly restricted. The ACLU is a great de facto friend of vagrancy.

Not that anything is easy in this area. The hard core of the homeless population is cut off from human relationships and finds the perverse freedom of the streets more appealing than the structure that would come with assistance. Many refuse help, either because they are too sick to make rational decisions or they don’t want to deal with any rules.

Eide suggests localities do more to nudge the homeless to make use of social services, and allow more dense housing to create a greater housing stock overall, thus reducing some of the upward pressure on rents.

But the beginning wisdom is to consider the status quo intolerable, and resist the advocates who want to normalize panhandling and camping, and the associated drug abuse, petty crime and disorder. Houston has had success with a tough-love policy of more services, coupled with a crackdown on encampments and other public nuisances.

One of the advantages of modern society is that people don’t have to live in public, or in squalor. That it is widely accepted in some of our greatest cities is an outrage of our age. It is deeply harmful to our civic life, and does no favors for the men and women living in parks and highway underpasses.