There is no universal and consistent reason for any legal penalty. Just collections of individual reasonings, by all the people who chose to codify them, or who inherited and retained them.
Looking at why people have been killed as a punishment over the millennia, I’ve seen everything from rule by terror, to laziness, to subtle theoretical notions, to pure practicality.
In my observation, most people advocating for or against it, tend to list more than one reason for their decision, most often, because whether THEY like all the reasons or not, they assume that having multiple reasons for something will gain them their way.
In addition, no matter what the original, or even the official current reason was/is for a death penalty, there will be people who urge it to be carried out for their own personal reasons.
For myself, I try to be as practical as I can. I am generally/mostly opposed to the death penalty, for entirely practical reasons, rather than emotional ones.
For one thing, I don’t agree with it being considered a “penalty.” This is because I think of a “penalty,” as being something that we use to persuade someone to modify their behavior. And death ENDS the person, so they aren’t being “penalized,” they are being eliminated.
Another element in my considerations, is an indirect one. Laws are like machines. Once they are put in place, they can be used, and often MUST be used on anyone and everyone, even when no one wants them to be. I suspect this is why we tried in many locales, to limit the use of the law, to fully adult humans.
In addition, laws give power to authorities. We try, in this country, to limit how much power authorities get in making life or death decisions, precisely because humans have a deep history of abusing power once they get a hold of it.
So I am wary in a general way, of supporting such an all-or-nothing “penalty.”
But there are valid concerns about how insanely dangerous some clearly defective humans are. There really are humans who are so viciously destructive, that only death will stop them from being destructive of everyone and everything around them. If anyone is detailed to hold such people in captivity, the expense has to be tremendous, just to allow any kind of safety at all for the caretakers.
Another practical consideration: killing everyone who commits horrible crimes, prevents us from being able to study them, and use the information to help us with future miscreants. We are much better at recognizing and catching serial killers and other sociopaths, because there was a time when the death penalty was outlawed and the captive examples were available for study.
As I said, all of what I listed, results in my being GENERALLY opposed to death, especially as a “punishment.” But I don’t fanatically and thoroughly oppose it, because I can appreciate that there are situations where nothing else is practical.
I don’t know enough about the Dylan Roof case to decide it for myself.