After the recession in 2008, Harriet Krzykowski was hired as a mental health aide at the Dade Correctional Institution, a prison in South Florida. Her salary was modest — $12 an hour.

But the low pay bothered her far less than hearing about guards visiting abuse on the mentally ill prisoners entrusted to her care. Some of these prisoners were being starved, Ms. Krzykowski was told. Others were locked inside a scalding shower. Among the prisoners subjected to this sadistic punishment was Darren Rainey, a mentally ill man who collapsed in the stall and died. Autopsy photos later leaked to the press showed that much of the skin on Mr. Rainey’s chest, back, and legs had peeled off.

When she learned of Mr. Rainey’s death, Ms. Krzykowski wanted to quit her job. But she couldn’t afford to. She needed the paycheck she drew to support her family. She also couldn’t report what had happened without risking retaliation from the guards, on whom the mental health staff in jails and prisons depend for their safety. So she kept silent.

Ms. Krzykowski could be viewed as an enabler and accomplice. But there is also another way to see her: as a worker performing a function that society tacitly condones but prefers not to hear too much about. I’ve spent the past few years researching the lives of such workers: mental health aides and guards who patrol the wards of America’s jails and prisons, many of which are rife with brutality and violence; Border Patrol agents who enforce America’s inhumane immigration policies; undocumented immigrants who man the “kill floors” of industrial slaughterhouses, where animals have hacked apart under brutal conditions in order to satisfy the popular demand for cheap meat; and drone operators who carry out “targeted killings” in America’s never-ending wars, which have faded from the headlines even as the number of lethal strikes conducted with little oversight steadily increased under Presidents Barack Obama and Donald Trump.

To the extent they are noticed at all, the people who perform such functions tend to be harshly judged, denounced for their involvement in or proximity to violence. Such judgments are not necessarily wrong, but they obscure an uncomfortable reality: We are all implicated in this dirty work, even if the people who do it are conveniently hidden from us.

“Dirty work” can refer to any unpleasant job, but among social scientists, the term has a more pointed meaning. In 1962, Everett Hughes, an American sociologist, published an essay titled “Good People and Dirty Work” that drew on conversations he’d had in postwar Germany about the mass atrocities of the Nazi era. Mr. Hughes argued that the persecution of Jews proceeded with the unspoken assent of many supposedly enlightened Germans, who refrained from asking too many questions because, on some level, they were not entirely displeased.

This was the nature of dirty work as Mr. Hughes conceived of it: an unethical activity that was delegated to certain agents and then disavowed by society, even though the perpetrators had an “unconscious mandate” from their fellow citizens. As extreme as the Nazi example was, this dynamic existed in every society, Mr. Hughes wrote, enabling respectable citizens to distance themselves from the morally troubling things being done in their name. The dirty workers were not rogue actors but “agents” of “good people” who passively stood by.

Contemporary America runs on dirty work. Some of the people who do this work are our agents by virtue of the fact that they perform public functions, such as running the world’s largest penal system. Others qualify as such by catering to our consumption habits — the food we eat, the fossil fuels we burn, which are drilled and fracked by dirty workers in places like the Gulf of Mexico. The high-tech gadgets in our pockets rely on yet another form of dirty work — the mining of cobalt — that has been outsourced to workers in Africa and to foreign subcontractors that often brutally exploit them.

Like the essential jobs performed by grocery clerks and other low-wage workers during the Covid-19 pandemic, this work sustains our lifestyles and undergirds the prevailing social order, but privileged people are generally spared from having to think about it. One reason is that the dirty work occurs far away from them, in isolated institutions — prisons, slaughterhouses — that are closed to the public. Another reason is that the privileged rarely have to do it. Although there is no shortage of it to go around, dirty work in America is not randomly distributed. It falls disproportionately to people with fewer choices and opportunities such as high-school graduates from depressed rural areas, undocumented immigrants, women, and people of color.

Many of these workers are victims in their own right, susceptible not only to exploitation and physical injury — as is true of so many people in low-status occupations — but also to another, less familiar set of hazards, owing to the unpalatable nature of the jobs they do. In their classic book, “The Hidden Injuries of Class,” the sociologists Richard Sennett and Jonathan Cobb called for shifting the focus of class analysis away from material conditions to “the moral burdens and the emotional hardships” that workers bear. For dirty workers, these burdens include stigma, self-reproach, corroded dignity, and shattered self-esteem. In some cases, they include “moral injury,” a term that military psychologists have used to describe the suffering that some soldiers endure after they carry out orders that transgress the values at the core of their identity.

“When a man — a good man, or woman — goes into prison, a little bit of your goodness wears off,” a former corrections officer named Bill Curtis told me. “You became jaded. You become more callous.”

The moral slide Mr. Curtis described may be particularly unsettling for those who are well-intentioned, including the legion of psychiatric aides who work in jails and prisons, which in recent years have effectively become America’s largest mental health institutions. As I have reported elsewhere, mental health staff routinely violate medical ethics by standing by while incarcerated people with mental illness are mistreated and abused. For example, in the months after Mr. Rainey’s death, Ms. Krzykowski lost her appetite. Her hair fell out. She struggled with guilt and shame and was eventually diagnosed with post-traumatic stress disorder.

Though more difficult to quantify, the moral and emotional wounds that many dirty workers experience can be as debilitating as a material disadvantage, shaping people’s sense of self-worth, their place in the social order, and their capacity to hold on to their dignity and pride. A result is a form of moral inequality that mirrors the economic kind. Just as the rich and poor have come to inhabit starkly different worlds, an equally stark gap separates the people who perform the most thankless, ethically troubling jobs in America and those who are exempt from these activities. Like so much else in a society that has grown more and more unequal, the burden of dirtying one’s hands — and the benefit of having a clean conscience — are increasing functions of privilege: of the capacity to distance oneself from the isolated places where dirty work is performed while leaving the sordid details to others.

To be sure, plenty of elite white-collar professionals — Wall Street bankers who sell shady financial products, or software engineers who design hidden spyware — do jobs that are morally suspect. But for white-collar workers who grapple with the ethical consequences of what they do, lavish salaries and bonuses can offset whatever discomfort they may feel. These elites are also less likely to be shamed and stigmatized for what they do than to be envied, lessening the impact of the ethical compromises they may feel they are making.

In my research, I have found that people from marginalized groups are not only more likely to do the dirty work in America, they are also more likely to be faulted for it, singled out as “bad apples” who can be blamed when systemic violence that has long been tolerated comes to light. This is not to say that they are not accountable for their actions. Though charges weren’t brought against them, the prison guards who put Darren Rainey in the shower deserve to be shamed and prosecuted.

But pinning the blame for dirty work solely on the people who carry it out can be a useful way to obscure the power dynamics and the layers of complicity that perpetuate their conduct. In prisons as elsewhere, the conditions that give rise to such work are a product of collective decisions, after all, reflecting our values, the social order we unconsciously mandate, and what we are willing to have done in our name.

In the case of Mr. Rainey’s death, the chain of responsibility extends not only to the Florida Department of Corrections but also to the governor at the time, Rick Scott, and the Republican legislature of a state that was spending less money per capita on mental health than every other state except Idaho. It also extends to many “good people” who voted these officials into office.

What we owe dirty workers is the willingness to see them as our agents and to grapple with our own complicity. We also owe many of them the right to have their stories listened to with respect and curiosity.

How might this look? One evening not long ago, I attended a ceremony in a small chapel at the V.A. medical center in Philadelphia, where a group of veterans gathered to talk about the moral injuries they had sustained while serving in America’s recent wars. One veteran sobbed while recounting an airstrike he’d called in that ended up killing dozens of Iraqi civilians.

After the veterans spoke, members of the audience formed a circle around them, linking arms and delivering a message that all dirty workers deserve to hear. “We put you into situations where atrocities were possible,” the audience members chanted in unison. “We share responsibility with you for all that you have seen, for all that you have done, for all that you have failed to do.”