Mosts of the posts on this thread have, quite understandably, focussed on the role of a Sentence in 'punishing' a convicted offender; all of theis leading, equaly understandably to the concerns about mistaken convictions and prisoners' re-habilitation.
However, there are other roles which Sentencing fulfills (or partly fulfills):
As a Deterrence to comitting the offence.
As a recompense to the victims.
To protect society at large from Convicted persons (if imprisoned or executed).
To re-habilitate and/or educate the Convicted persons.
Perhaps the Deterrence is the strongest and often under-appreciated (since society also uses its own regulatory behaviours to treat certain unwanted behavious as abnormal). The effect of Deterrence in Sentencing is illustrated in this thought-experiment:
"Imagine that the Sentencing Tarrifs were reversed, so that the most lenient of Sentences were applied to the most severe but rare crimes and the most severe Sentences were applied to the most trivial but frequent and socially disruptive crimes. eg A minor fine for murder and the Death Sentence for a Parking violation."
The argument goes that Murder is usually committed under such extremes of overwhelming emotional impetus that a consideration of the likely Sentence (the Deterrent) is hardly likely to influence the outcome, whereas double parking is so easily avoided and open to reflection beforehand, that the Death Sentence is likely to be a very effective Deterrent. See Rummel vs Estelle - US Supreme Court.
Please, don't get bogged down in the details of applying the thought-experiment, its simply intended to help us to evaluate these various roles that Sentencing offers a society from a broader and wider viewpoint before we do what lawmakers usually do - before we make more laws merely as a reaction against a the details of the previously introduced law.