People have a natural right to protect themselves, using lethal force when necessary, so it reasonably follows that use of lethal force is a power that we may delegate to the governments we create.
In terms of theoretical bases for systems of governance and what powers a government may legitimately excercise, "the death penalty" is less offensive to reason than, say, taxation.
But calling it "the death penalty" upends the relationship between governments and the people who create them. The government is not your dad and is in no position to be "punishing" you.
The primary rationale for considering government justified in harming a person it not punishment, revenge, deterence, rehabilitation, restoration, etc. It is separation.
And the function of separative justice is to preclude the criminal from committing further crimes against free society and its members for the duration of the criminal's sentenced separation from free society.
The discussion of what crimes or offenses we permit the government to claim justify harming a person (i.e., what laws we create to define what the government can claim as justification) is a separate topic, but when you understand that the form of the harm the government is permitted to commit should be thought of as separation from free society, a death sentence is just a logically consisten extension of that separation to indefinite/permanent duration.
All that said, it's also reasonable to hold the position that governments are not trustworthy enough to be delegated an authority to sentence a person to a separation from free society of permanent duration; so even if the theoretical basis may be sound, you can still oppose it as a matter of practice.
Though if a fallible government taking life of an innocent person is something you find significantly worrisome, taking a whole life all at once (via execution), taking a whole life one day at a time (via imprisonment until death), or taking life only partially (via a sentence of fixed duration) all raise this concern.
There's also some irony when people who are so concerned with the government taking the life of an innocent person found guilty by mistake also point out that sentencing someone to death by imprisonment is much cheaper than sentencing someone to death by execution... since the former skips all the very expensive checks and doublechecks to ensure the State isn't taking the life of an innocent person.
Handwaving about how an innocent person sentenced to death by imprisonment COULD still be released if exonerated ignores that they probably won't be. Did you know that you can have your filings to appeal rejected without consideration on the basis of "timeliness" after as little as three years into a life sentence? It's not that your appeal is without merit, they don't know/care if your appeal has merit or not (that's what "without consideration" means), it just took too long to figure out how to properly file the paperwork. Maybe you've spent those three years repeatedly filing to appeal and having them rejected on technicalities... you used 8.5x11 letter-sized paper, not 8.5x14 legal-sized paper; it was hand written, not typed; your margins were too small; your font wasn't large enough; it needs to be double-spaced; it was insufficiently concise, keep it to one sheet of paper; you didn't cross all your t's and dot all your i's; et cetera.
If only you, dear innocent person, had been sentenced to death by execution, then you'd still have legal counsel to make sure you didn't keep having your filings rejected for dumb reasons. Also such rejections without consideration due to technical deficiencies may not be allowed at all. Also, also, you get a mandatory appeal.
And then people will tell you that, in addition to saving all that taxpayer money by not making sure whether the person is innocent, execution is a merciful release compared to the ongoing suffering of spending every day locked in a cage to Think About What You've Done.
Which is, BTW, a very non-criminal way of thinking. A non-criminal finds a potential death sentence to be a deterrent because they think about how they don't want to be sentenced to death. A criminal does not find a potential death sentence to be a deterrent because they think they won't get caught. Or if caught, won't get charged. Or if charged, won't be prosecuted. Or if prosecuted, won't be found guilty. Or if found guilty, won't be sentenced to death. Really, that "death sentence" boogeyman is some way-off thing that won't happen until after you've eaten breakfast at least. And what if you didn't eat breakfast?