BEN CARSON said last week that Facebook is “discriminating against people based upon who they are and where they live.” He has a point. But the housing secretary’s concern is curious, given the hostility toward anti-discrimination efforts he has previously manifested.

Mr. Carson announced on Wednesday that his department had lodged a complaint against the social media platform for “encouraging, enabling, and causing” unlawful discrimination through its targeted advertising system. The argument is one that civil rights advocates had already been making: Facebook’s tool is popular and powerful because it allows firms to reach the precise audience they wish. Sometimes, firms wish to exclude minorities and women, either directly or through digital redlining by Zip code. Facebook makes it easy.

This is a real problem. It is also one that Facebook was already trying to fix. The company eliminated affinity categories from its targeting options for housing, employment and credit ads last year. Last week, Facebook, which says it was also in talks with the Department of Housing and Urban Development until discussions fell apart over the agency’s request for almost limitless access to user data, settled with private groups challenging its policies with a pledge to overhaul its system. HUD’s inquiry may have helped prompt Facebook’s decision, and the department’s complaint does land on a new and important issue: algorithms that maximize engagement with ads, leading to those ads being displayed — or not displayed — only to a protected group.

Still, some skepticism is warranted. HUD says its fair-housing office is engaged in enforcing the Fair Housing Act every day, and that the Facebook action is just an example. But as a matter of policy, the housing department under this administration has seemed more interested in dismantling housing protections than ensuring they are respected. Mr. Carson has unraveled an Obama-era rule requiring communities to address patterns of segregation, scaled back investigations and removed the words “inclusive” and “free from discrimination” in his agency’s mission. He has said before that he considers federal integration efforts as “failed socialist experiments.”

It seems surprising that HUD’s latest enforcement experiment is aimed against a social media site, given platforms are traditionally shielded from prosecution for what people do or post on them. But the choice is less shocking in the larger context of conservative politics.

Mr. Carson makes his move against Facebook as Republicans on Capitol Hill and in the White House lash out against tech companies for their supposed left-leaning censorship. They are threatening to remove sites’ immunity to prevent so-called viewpoint discrimination, and HUD’s charge that Facebook is liable for advertisers’ unfair practices is a sign that the administration is serious about scaling back these treasured protections. In other words, the right thing may be happening for the wrong reason.

Read more: