To quote a post I recently found resonating with me:
"Look, we don’t necessarily hang murderers to deter other people from committing the same offence. We kill them simply because the punishment has to carry the same weight as the offence. The family of the murderer must go through the same anguish and pain that the murder victim’s family went through. The killer has to be stopped from enjoying all the things that come with being alive. When you kill another person, you deprive them of worldly enjoyments like food, sex, conversations, bathing, laughing, crying and therefore it is only befitting that you too get deprived of same and the only way to do so is through the death sentence. If we are going to shy away from punishing wrong-doers on the basis that the punishment won’t stop other people from committing the same offence then we might as well not send anyone to jail because sending people to jail has never stopped other people from committing the same offences."
https://www.sundaystandard.info/iocom-a-retributionist-i-sup...
The pact the government has with people is that the government metes out justice so that people don't try to get it themselves. Some measure of retribution, it doesn't need to be the death penalty, works towards this goal. If people believe the courts will punish a criminal they are less likely to do it themselves, it reduces the risk of vigilante justice. That's a good thing because vigilantes are less discerning about getting the right person and considering extenuating evidence. It's a compromise.
Imagine the government found a way to cure psychopathy with a pill. They catch a serial killer who brutally murdered dozens of people, utterly rehabilitate him with their pill and release him the same day. This might satisfy you and some of the other wise and enlightened commenters in this thread, but many people would not be satisfied with it and people would be more inclined to kill murderers in retribution, since the government no longer punishes them.