I think we as a society would have a lot more to gain by deeply studying our worst criminals instead of killing them. Like, use mind altering drugs on them and have psychiatrists delve into their past, their traumas, investigate medical histories, family histories, etc. No stone unturned. I know we do that to some extent, but not to any sort of full extent. You already don’t care about their human rights if you’re going to kill them, so why care about drugging them and studying what made them turn out so bad in the first place?
Also, no one is being taught a lesson by killing them, it doesn’t deter future criminals, it doesn’t rehabilitate anyone, it just makes the people outside the prison feel better and that’s kind of a shit reason to kill someone. And it’s a waste of potential insight that could help us to actually prevent these horrible crimes from happening in the first place.