The execution chamber at the Oklahoma State Penitentiary in McAlester, Okla., in 2014. (Sue Ogrocki/Associated Press)

IN JUST a few months, Donnie Myers’s long and lethal tenure as a top prosecutor in South Carolina will come to an end. If past is precedent, so will the bumper crop of death sentences in his jurisdiction.

Mr. Myers, known locally as “Dr. Death,” has personally secured 39 death sentences against 28 defendants — some were tried twice — in a 38-year career as solicitor of South Carolina’s 11th Judicial District. He is notorious for keeping a paperweight model of the state’s electric chair on his desk, for his race-baiting courtroom histrionics, and for playing fast and loose with legal rules. According to an analysis by Harvard Law School, courts have found he committed misconduct in 46 percent of his capital cases, and six death sentences he secured were subsequently overturned.

Mr. Myers, who has been convicted of drunken driving and, recently, charged again for the same offense, could usher in a big change when he retires this year. If South Carolina’s 11th Judicial District follows what has become a pronounced pattern, the exit of one overzealous prosecutor could bring about a sharp drop in the imposition of the death penalty.

That is among the findings of Harvard Law School’s Fair Punishment Project, which surveyed the wildly disproportionate impact of a handful of fanatical state prosecutors. Even as the frequency of death sentences and executions in the United States has plummeted in recent decades, the Harvard study shows how the nation’s death rows, which currently house about 2,900 convicts, have been populated by the efforts of a very few, death-penalty-loving men (and, notably, one woman) like Mr. Myers.

The report’s findings underscore the grossly arbitrary nature of capital punishment in this country and undercut whatever legitimacy it may retain. If imposition of the ultimate punishment is to a great extent driven by personality and a hunger for notoriety, then it is the antithesis of justice.

How else to think about prosecutors such as Dale Cox, just retired as the top prosecutor in Caddo Parish, La., who declared, upon learning of the exoneration of a man who spent 30 years on death row for a crime he did not commit, “I think we need to kill more people.” Mr. Cox, who secured a third of Louisiana’s death sentences in a five-year period ending in 2015, had a simple rationale: “Revenge brings to us a visceral satisfaction.”

The good news is that the number of states allowing capital punishment has shrunk and, in states where the penalty remains active, U.S. juries have mostly lost their appetite for it. Just 49 death sentences were handed down last year, an 84 percent drop from the modern-era high of 315 in 1996.

Nonetheless, in the shrinking numbers of counties where the capital punishment remains in fashion, it’s striking how few prosecutors dominate death-sentencing statistics. They are evidence, the Harvard study concludes, “that the application of the death penalty is — and always has been — less about the circumstances of the offense or the characteristics of the person who committed the crime, and more a function of the personality and predilections” of a very few prosecutors.