The Death Penalty is not a deterrent, nor has it ever been.
Its role has been to take Revenge out of the hands of the family and friends of the victim, and to put it into the more methodical and dispassionate hands of the State.
Revenge... for the victim, primarily, and, secondarily, for the victim's family and friends, and even, in a tertiary sort of way, for the community at large, for thus damaging and weakening and disturbing the community.
Revenge.
It has been thus, since the earliest times, when the payment of 'wergeld' (blood money) and eye-for-an-eye personal violence were taken out of the hands of an aggrieved peasantry and put into the hands of the local nobility of a post-tribal, feudal, pre-medieval Europe.
In that respect, nothing has really changed since those earlier times.
Except that nowadays, the State exacts that Revenge through a long, drawn-out legalistic Danse Macabre - tightly controlled and monitored, to ensure the fewest possible mistakes.
Usually, the system works.
Sometimes, it doesn't.
But let's not forget how State-sponsored Capital Punishment got its start, and why it has been sustained for so many long centuries - fulfilling, as it does, a basic human need.
Revenge.