Retribution, punishment because we are upset at what someone has done is pointless. It is revenge cloaked in justice.
That being said rehabilitation shouldn't be the only consideration. There is also incapacitation (locking someone up to protect society), deterrence (punishment has to be severe enough to make someone think twice before committing the crime), and restitution (if it's possible for the person to do something to make up for the crime they should have to do that).
The US has one of the largest prison populations in the Western world. Obviously, locking up millions of people has not helped the crime situation. Where possible we should aggressively seek rehabilitation measures in order to help our citizens get better and be productive members of society. We should not just always lock them up.
I believe that rehabilitation is a better basis for determining sentencing than retribution. Of course, that depends on the crime that has been committed. If a person has committed a crime for the first time and shows genuine remorse for what he or she has done, then the person should be given a second chance. Sometimes people just make bad choices, such as getting into drugs and committing crimes, and rehabilitation is a better option.
Jail causes crime rate down and allows certain people too forget the past and create new lives for themselves. Sure some gangs are created in jail but if we change how our jails treat the prisoners we might b able to end most gangs and lower crime rate by a lot.