Generally speaking, there are three models of punishment that provide an explanation for the rationale behind various components of the criminal justice system. The first, deterrence, operates on the idea that fear can discourage a person from behaving in a certain way. General deterrence refers to the fact that when members of society see the hardship that befalls individuals convicted of a crime, they are less likely to engage in those criminal behaviors themselves. Specific deterrence, in contrast, focuses on the individual; because they know how bad incarceration can be, and because they want to avoid that at all costs, they will refrain from engaging in criminal activity so as to avoid the corresponding punishment.
A second model of punishment is incapacitation; by incarcerating an individual found guilty of a crime, the general public is protected. Because the offender is all but removed from society, the innocent feel as though they are safer, or more protected, than they might be on the outside of that corrections facility. While incapacitation clearly works within the construct of the model of punishment, it is very cost intensive to incarcerate individuals, particularly with the frequency of other guests during a peak time.
Finally, a third punishment model is rehabilitation. The goal in this punishment model is to change the individual in such a way that they never commit the crime again. This can come through opportunities for those incarcerated to take advantage of educational opportunities, or it can be through the medical field, providing drug and alcohol rehabilitative services to the individual in the hopes that they will emerge a better, and wiser, person.