Well there are three main concepts for punishment in a given criminal justice system. Deterrence, Rehabilitation, and prevention of further harm. Each has a role, so using aligning punishments wisely is supposed to be the role of the criminal justice system. All three are ideally aimed at proactive crime prevention, rather then reactive vengeance. In America we are not great at this, it is doubtful there is a perfect solution, but ours seems exceptionally bad.
Deterrence is the go to motivation for our "Tough on crime" politicians. The problem is they don't seem to understand what it does, and does not do. Deterrence works well for small crimes, and generally those where the criminal rationally weighs out the consequences of their actions. Deterrence can keep people from parking in handicap places, or prevent people from littering, or cheating on their taxes. It tends to be completely useless at dealing with crimes of passion or mental health crisis, because those tend to have no consideration of consequences, so no deterrent is considered. In my opinion, Deterrence is totally useless in capital cases, and should not be considered for punishments more severe then approximately one year in jail (Mostly it should be fines).
Rehabilitation is not really a "punishment" at all. It is a set of methods to curb anti-social behavior and reintegrate offenders. As such, it doesn't really need "sentences" in the first place. The extent to which a person needs rehabilitation is specific to the person, not the offense. A minor drug possession charge might need a great deal of rehabilitation to deal with addiction and the life issues that led to that addiction, but a prison is a terrible place to provide that rehabilitation.
Lastly, preventing further harm. This is where capital punishment usually falls. They are typically not the sort of crimes that can be prevented by deterrence, and often the chances of rehabilitation are slim to none. This is not the majority of criminal cases, but it does apply to people like serial sexual predators, certain types of murderer, and so forth. In this case, the realistic options come down to the death penalty or life in prison. If they can't be rehabilitated, then society needs to be protected from them. Which you prefer depends on if you believe the death penalty is more or less humane then locking someone in a room forever. I personally prefer the death penalty, but life in prison has the significant benefit of being reversible if you find out you wrongfully convicted someone. So if you don't trust the criminal justice system much, life is a better call.
edit: Is anyone else super confused by the picture in the OP? Why is there a smiling stock photo of a telemarketer in this topic?