There are three reasons people commit crimes: Profit, passion, and pathology.
People who commit a crime during a period of emotional duress- Crimes of passion- need counselling. With the proper treatment, they are unlikely to repeat their offense, or at least the risk can be greatly mitigated.
People who commit a crime because they expect to gain something- Money, power, secrecy, whatever- They need to be punished, they need to make restitution when possible. Deterrents are actually effective against them in many cases, and it is often possible for them to “pay their debt to society” and move on.
People who commit crimes because they can’t help themselves, or out of the sheer joy of it- child molesters, serial killers, violent sex offenders- They can’t be cured, they can’t be contained. They need to be put down like rabid dogs. And quite frankly, if the only type of justice or closure that their victims can have is seeing them twist on a rope, I’m not exactly going to shed tears over it.
Prison the way we currently handle it, causes more problems than it solves- and just because prisoners are assaulting, murdering, and raping each other doesn’t mean it’s less of a crime. When you have people who begin to feel more comfortable inside a prison than out, it’s no longer a punishment or a deterrent.
Take someone vicious, capable, and unrepentant: Keeping them in full-time solitary is cruel and unusual. Killing them is cruel and unusual. Allowing them contact with other prisoners puts their lives in danger. So what do we do? Justify allowing them to murder each other? Or try to split hairs on which punishmet is less cruel and unusual?
There are no good answers here. Only bad and innefective choices, or bad and consequential choices. I prefer to err on the side of leaving the most options available.