Goals of punishment
First, understand that a punishment can have four effects:
Incapacitation. The person being punished can be prevented from committing additional crimes by having their freedom curtailed.
Retribution. Because society punishes the criminal, the victims don't have to try for revenge.
Deterrence. Knowing that punishment exists can prevent people from committing crimes in the first place.
Rehabilitation. The punishment can include provisions that encourage the criminal towards law abiding pursuits in the future.
Various punishments can be better at various aspects. For example, drug programs may focus on rehabilitation, where they try to get addicts to stop using drugs. Incarceration addresses all four effects and is effective in about the same order as listed.
Capital punishment only addresses the first three effects, again in the listed order. But it is the most effective at incapacitation. Once executed, people do not commit more crimes. Even someone incarcerated for life can still commit crimes against other prisoners and against guards.
Capital punishment is effective as retribution. Victims are generally satisfied with it as a punishment. Incarceration is again slightly less effective, as victims either want the period to be longer or for it to be upgraded to capital punishment.
Deterrence is controversial. There have been studies showing that capital punishment has a mild deterrent effect, particularly in terms of escalation. Other studies have claimed to show no effect. Pretty much the same thing is true of incarceration. The basic problem is that most criminals do not expect to get caught. Even very mild punishments, like speeding tickets, can be effective if the chance of getting caught is high. Even very significant punishments are not effective if most people expect to get away with it.
Capital punishment is useless for rehabilitation, but incarceration isn't much better. Yes, it's possible to take classes and learn skills while incarcerated, but felons have a much harder time finding law abiding jobs. Some jobs aren't open at all, and other jobs can be hard to find.
Escalation
There was a period of time in California when kidnapping was a capital crime. What they found was that this increased the number of victims killed, since kidnapping and murder had the same punishment and live victims could potentially help catch their kidnapper. But while this was an argument against kidnapping being a capital crime, it was an argument for murder being a capital crime. Because if the worse possible punishment was the same for both crimes, kidnappers were murdering. So in that situation, the claim was that capital punishment was seen as a greater deterrent than incarceration.
The counter argument of course is that you can change things such that neither is a capital crime but there are different periods. E.g. life for murder and twenty-years for kidnapping. The problem comes when getting caught for one crime will inevitably lead to detection of other crimes. Five twenty-year sentences may as well be a life sentence. We're back to the original problem of the sentences being the same, at least in effect.
This can be generalized to any situation where the criminal can kill a victim. We want the punishment for murder to be higher than whatever punishment would be given without it.
Law enforcement
Killing a law enforcement officer is often a capital crime. One reason for this is that it is easier to get people to surrender if they know that the punishment will be better that way than if they shoot and kill an officer. And criminals resisting is dangerous. Not only might they injure or kill an officer, they might kill someone totally unrelated while trying to shoot the officer. For example, a stray shot might go into a house and kill a toddler.
A similar situation exists with corrections officers. Because the criminal is already incarcerated, threatening with incarceration is distant. They may even already be jailed for life, in which case we're back to the escalation problem. In practice, they have some options in terms of making incarceration worse, but most aren't intended as punishments.
Cost
In the United States, it is more expensive to execute someone than to incarcerate for life. This is because the cost of prosecution goes up. It is much easier to appeal death row sentences. The increased court costs outweigh the cost savings of execution over incarceration. That does not have to be true though.
If the court costs are the same for both, then capital punishment is going to be cheaper. This may well be less fair, as presumably the longer appeal process removes more innocent accused people.
In general, one of the main criticisms of capital punishment is that it is not cancelable. While this is true, note that incarceration is only partially cancelable. Yes, the inmate can be released before the end of the sentence, but the inmate can't get back the already incarcerated term. Until the moment of execution, the capital punishment is just as cancelable as the incarceration.