I think I probably mentioned this before on the forum, but a professor in an ethics course argued that the death penalty was not a deterrent to crime. I was persuaded of his sophistry for a while in my young adulthood. It seems to me that, though your language of it being unnecessary may be true, it is certainly legally justified, and it may serve to let potential bad actors know what they will face. It might serve as a deterrent, might not. But all of the online hand wringing about it being barbaric and only done in the tyrannical authoritarian regimes is simply bogus.