According to [Cesare] Beccaria, punishment has two fundamental objectives: to restrain the criminal from committing additional crimes and to deter other members of society from committing the same crime. The first purpose is served by imprisonment, so we are left with the issue of deterrence.
Not so fast! Imprisonment obviously does not prevent criminals from committing additional crimes since criminals continue to commit all sorts of crimes in prison, including murder. Execution of murderers, however, is a most effective means of restraining them from committing additional crimes. It works every time.
Just as dead men tell no tales, dead men commit no crimes. Does it follow that we ought to exterminate humanity to prevent crime? I don't think so!
The topic of deterrence raises the following question. Suppose the execution of a murderer has no deterrent effect whatsoever. Would the execution be nonetheless morally justified? I should think so, on retributivist grounds. Retribution, impartially administered by the state apparatus, is not revenge, but a form of justice. Immanuel Kant takes this line in perhaps its most rigoristic form.
Justice demands capital punishment in certain cases, and it doesn't matter what it costs, or whether there is any benefit to society, or even whether there is any society to benefit. Recall Kant's last man scenario from Metaphysics of Morals, Part II (emphasis added):
 But whoever has committed murder, must die. There is, in this case, no juridical substitute or surrogate, that can be given or taken for the satisfaction of justice. There is no likeness or proportion between life, however painful, and death; and therefore there is no equality between the crime of murder and the retaliation of it but what is judicially accomplished by the execution of the criminal. His death, however, must be kept free from all maltreatment that would make the humanity suffering in his person loathsome or abominable. Even if a civil society resolved to dissolve itself with the consent of all its members--as might be supposed in the case of a people inhabiting an island resolving to separate and scatter themselves throughout the whole world--the last murderer lying in prison ought to be executed before the resolution was carried out. This ought to be done in order that every one may realize the desert of his deeds, and that blood-guiltiness may not remain upon the people; for otherwise they might all be regarded as participators in the murder as a public violation of justice.
Kant's view in this passage is that capital punishment of murderers is not just morally permissible, but morally obligatory. (Note that whatever is morally obligatory is morally permissible, though not conversely, and that 'morally justified' just means 'morally permissible.')
Here is another interesting question. The U. S Constitution grants a near-plenary power of pardon to the president. (Here I go again, alliterating.) Does this extend to convicted mass murderers such as Timothy McVeigh? If yes, then Kant would not be pleased. The president would be violating the demands of retributive justice! This of course is a secular analog of the old theological problem of justice and mercy.
Memo to self: bone up on this! See what Carl Schmitt has to say about it specifically. Cf. his Political Theology: Four Chapters on the Concept of Sovereignty, University of Chicago Press, 1985, p. 56:
All significant concepts of the modern theory of the state are secularized theological concepts not only because of their historical development—in which they were transferred from theology to the theory of the state, whereby, for example, the omnipotent God became the omnipotent lawgiver—but also because of their systematic structure, the recognition of which is necessary for a sociological consideration of these concepts. The exception in jurisprudence is analogous to the miracle in theology.