The purpose is neither to punish, nor to rehabilitate: A perfect criminal justice system is one that prevents future crime, while at the same time minimizing how many people aren't doing something useful with their lives. Imprison or kill someone that could be helping society, and you are failing too.
Punishment and rehabilitation are just parts of achieving the goal: Punishment tries to prevent further crime, both by the person being punished, and people that know what will happen to them if they are caught. Rehabilitation is great when it succeeds: Sending a rapist out to do more raping isn't so great.
All of our policies about punishment, rehabilitation and enforcement quality are tradeoffs, and the question is what's the best tradeoffs. The biggest one, IMO, has little to do with the size of the punishment (they are all pretty big), but with deterrence. Nobody is going to stop killing someone because they'll "only" get 15 years in jail. 15 years in jail is horrible for most people that aren't living in terrible conditions outside. The real kick is in chances of getting caught. The criminal believes that he won't get caught, so the size of the punishment is not necessarily that relevant, other than in keeping the person that committed the crime away from doing the same again outside of jail (crime vs other immates happens!). Improved enforcement quality, and making sure that people just don't even want to do criminal things, regardless of the punishment, is where it's at.
The problem with that is that enforcement itself is a tradeoff: We could do a lot to prevent crime in NYC if 25% of people were in some form of law enforcement (including policing the police), but it'd be a tradeoff we'd all be unwilling to make, because it'd be very wasteful.
Punishment and rehabilitation are just parts of achieving the goal: Punishment tries to prevent further crime, both by the person being punished, and people that know what will happen to them if they are caught. Rehabilitation is great when it succeeds: Sending a rapist out to do more raping isn't so great.
All of our policies about punishment, rehabilitation and enforcement quality are tradeoffs, and the question is what's the best tradeoffs. The biggest one, IMO, has little to do with the size of the punishment (they are all pretty big), but with deterrence. Nobody is going to stop killing someone because they'll "only" get 15 years in jail. 15 years in jail is horrible for most people that aren't living in terrible conditions outside. The real kick is in chances of getting caught. The criminal believes that he won't get caught, so the size of the punishment is not necessarily that relevant, other than in keeping the person that committed the crime away from doing the same again outside of jail (crime vs other immates happens!). Improved enforcement quality, and making sure that people just don't even want to do criminal things, regardless of the punishment, is where it's at.
The problem with that is that enforcement itself is a tradeoff: We could do a lot to prevent crime in NYC if 25% of people were in some form of law enforcement (including policing the police), but it'd be a tradeoff we'd all be unwilling to make, because it'd be very wasteful.
So it's nowhere ear as simple as you paint it.