160 years ago in 1865, slavery was outlawed except as punishment for a crime. This posed a severe shortage of cheap labor, which was solved by creating a plethora of fiddly little crimes targeting the poor and marginalized. The next 75 years, the role slavery filled was instead covered by convict leasing and prison peonage, ending only when FDR issued a circular ordering prisons to stop the practice because we were about to enter WW2 and it made us look like the bad guys. To replace the cheap labor of convict leasing, prisons instead became factories. Prisoners are technically paid now: they dont have access to the money, and it only goes towards paying bail as well as other expenses, but they are technically being paid for their work. Therefore, it's not slavery! ๐ค
This is the pragmatic reason why prisons exist: because slavery is illegal. We made up the moral reasoning because deep down we know it's wrong. Back in the pre-civil-war era, we also had justifications for why slavery was good: the slaves were incapable of making moral decisions, we were civilizing a barbarous people, etc etc. It was bullshit then, and it's still bullshit now.
In every D&D campaign I have run, the players have come across a community of "inflated earthers" who believe the earth is a balloon, and that digging too deep could cause the planet to sag or pop. In every campaign, they are right.