It's more complicated than that. The criminal justice system serves three purposes: rehabilitation of the offender, where possible; segregation of the offender from potential victims; and deterrence, i.e. to serve as an example to dissuade future offenders.
In situations where rehabilitation is possible, that should obviously be the goal. But there are situations where rehabilitation is impossible, thus logically necessitating indefinite segregation. This is where the argument for capital punishment comes in, because the only difference between a lifetime of segregation from society and death is a million dollars in tax money; both serve the same purpose to society at large, and one makes a lot more sense.
Where capital punishment fails, however, is as a deterrent to future offenders. Methods of execution like hanging, electrocution, paralytics and, yes, a bullet to the head, have all proven themselves to be too agreeable of a fate to prevent certain people from engaging in certain behaviors, which is why you historically need the threat of a lifetime of tax-subsidized nigger rape.
Unfortunately, as we are seeing with this recent crop of offenders, pedophiles are disproportionately massive fucking faggots who absolutely love the idea of a lifetime of tax-subsidized nigger rape, which is why we have to explore other possibilities like flaying, immolation, putting them through the woodchipper, or making them try to submit a post on kiwifarms while null is fucking with the database.