Let me give you the libertarian perspective.
There are certain purposes for punishing wrongdoers. The most important is to prevent subsequent misdeeds. Primarily by the wrongdoer. Keeping him locked away is one way to accomplish that. Rehabilitation is better. If he's a member of an organized terrorist group you have a problem, however. His buddies will kidnap a bunch of your people and offer to trade them for the prisoner. So it's probably ok to execute terrorists who are not acting alone like Timothy McVeigh. That's a tough decision but it seems like an exercise in situational ethics, picking the lesser of two evils.
Punishing people by making them fix something they broke or paying back money they stole is restitution. That is another very good reason for punishment. To the extent that the misdeed can be corrected, this sorts the universe out a little bit and makes the perp pay for his deed in a way that is directly related to the deed itself. Not bad. It doesn't work for murder or rape but it works for a lot of lesser crimes.
They say that punishing people as an example makes the rest of the population toe the line and not break the law. I think that's not true so I don't buy this excuse for punishment, certainly not for the death penalty or torture (or rape).
If you live in a country where the civil authorities don't have much power or can't be counted on for continuity, prisons may not work. Ancient Mesopotamia or modern Russia, where the people in the government take bribes to allow terrorists on airplanes, are good examples. In places like that I suppose the only way to keep a person from committing more crimes, assuming that you haven't got a good rehabilitation program, is to kill them.
And of course if you catch someone in the act of attacking your family with a lethal weapon you have the right to defend them with lethal force of your own. But if you go to all the trouble of overpowering him, tying him to a chair, waiting for the cops, going to trial, being shaken down by the defense attorney, and hoping you made the right choice, the last thing that should be done is for the government to go ahead and kill him anyway. Why bother having a government if it's just going to do the one thing that we private citizens are not supposed to do under any circumstances: take revenge?
Revenge is never a legitiminate reason for punishing someone.
Killing someone only punishes the people who love them. Like their children, who don't understand what's going on except that you're the bastard responsible for killing their father. All that gets you is an endless escalating cycle of revenge like the stereotyped feuds in the American backwoods. Or the thousand-year-old hatreds in the Middle East, where the definition of a "moderate" is a person who only holds a grudge for six generations.