White House press secretary Sean Spicer has one of the hardest jobs in Washington. He’s almost constantly under fire from an increasingly unsympathetic public and the frustrated reporters he works with every day. He must be the first White House press secretary whose battles in the briefing room are so memorable that they’ve inspired their own recurring sketch on “Saturday Night Live.” As the president has reportedly told people, “the guy gets great ratings.” And his missteps make news.

Witness Spicer’s comments in April that Adolf Hitler “didn’t sink to using chemical” weapons the way Syrian President Bashar Assad had. The comment was wrong, deeply hurtful and even led to accusations that he was denying the Holocaust.

Spicer quickly apologized, but his stumbles, both unnerving (as when he referred to concentration camps as “Holocaust centers”) and funny (like calling Canadian Prime Minister Justin Trudeau “Joe”), get headlines. His relationship with the press is, at best, fraught. Yet contrary to popular belief, Spicer is actually doing a good job. Not for reporters or the general public, who disagree with that assessment. But Spicer doesn’t answer to them; he answers to the president. And he has served President Donald Trump well in two important ways.

First, Spicer has succeeded in fanning the flames of the feud between Trump’s White House and the media. To be clear, the administration actively fighting with the press is a bad thing, and the president labeling several major outlets as “the enemy of the American people” is terrible for the republic. Nonetheless, the White House views this antagonism as in its best interests — which makes sense, in a deeply cynical way.

Earlier this year, a Fox News poll of registered voters found that Trump administration officials were trusted slightly more than news outlets. As Gallup found in its annual “confidence” survey last September, public trust in the news media is at an all-time low: Just 32 percent of respondents said they had a “great deal” or “fair amount” of trust in the press. Among Republicans, that number was even lower: Just 14 percent expressed confidence in the fourth estate. Fair or not, the Trump White House has calculated that it can improve its own popularity — and further undermine the credibility of entities they view as hostile — by relentlessly attacking the news media. Hence, Trump dismisses respectable outlets like CNN as “fake news.”

Spicer has been an active participant in this fight with the media. During his very first briefing, he famously blasted the press over its reports on the size of Trump’s inaugural crowd. He once scolded April Ryan of American Urban Radio Networks to “stop shaking [her] head” while he was speaking. He treated the New York Times’ Glenn Thrush like a child, telling him “it’s not your job to yell out questions.” He threatened to throw CNN’s Jim Acosta out of a news conference. He accused Time’s Zeke Miller of “deliberately false reporting.” Spicer has done a good job picking the fight the Trump administration wants to have.

The other measure of Spicer’s success is his steadfastness in defending the president. By unconventional means, he has succeeded there, too: Intentionally or not, Spicer has done an excellent job of jumping on the grenade. When the president or the administration have made a mistake, Spicer has succeeded in deflecting attention by making himself the story, often at the expense of his own image and credibility.

Take the botched rollout of Trump’s ban on travel from seven majority-Muslim countries, a move executed so poorly that even fellow Republicans lambasted the administration. Spicer did his job and took to the podium for a testy exchange with reporters, providing material that became the source of Melissa McCarthy’s impersonation on “SNL.” Attention to the administration’s original misstep waned, even as Spicer became the butt of more jokes.

Or take Spicer’s false claim that the Obama administration used British intelligence to surveil then-candidate Trump, an accusation that came as the White House was under siege following Trump’s disproven claim that Obama had tapped his phone. After Spicer’s comment, the attention shifted from Trump’s false claim to Spicer’s; Spicer came out looking unprepared and ill-informed, but he was able to staunch the bleeding for his boss.

This is all terribly cynical, of course. A strong, adversarial free press is critical to the functioning of our democracy, and it keeps the worst abuses by the powerful in check. Undermining confidence in it is selfish and short-sighted. And when the Trump administration’s actions force journalists to cover something trivial — like whether Spicer is about to be fired or whether he called journalists “silly” — vital matters go underreported. The press is best able to serve the American people when it can focus on major issues, like whether going to war with North Korea is wise, or how the administration intends to follow through after its missile strikes in Syria.

Spicer and this administration’s approach to the news media is ultimately bad for the American people. But Sean Spicer doesn’t answer to the people; he answers to Donald Trump. And as long as Spicer continues to do the job the he was hired to do — picking fights with the news media, distracting the press with triviality and protecting the president’s reputation at great cost to his own — you can expect President Trump to keep him around.

Neal Urwitz is director of external relations at the Center for a New American Security.