There are a few factors to consider when someone is punished for a crime.
Rehabilitation Over Punishment
The primary goal should always be to rehabilitate people. If someone can be rehabilitated they can be a productive member of society. If they can’t they must be imprisoned or monitored and be purely a drain on society.
Satisfaction Of The Wronged
Those that have been wronged should feel that the perpetrator was punished appropriately for that wrong. If someone’s spouse is murdered, even if the perpetrator is quickly rehabilitated, society must maintain a sense of justice and have appropriate punishments meted out.
Favor Penance That Contributes
Sitting in prison doesn’t contribute to society. Concepts like community service help society and should be more beneficial to people who have committed crimes.