1) Primarily to remove dangerous or disruptive individuals from society for as long as they continue to pose a danger.
2) Rehabilate and educate people who became criminals due to a poor upbringing or lack of opportunity, and to move people into medical or psychiatric treatment when relevant.
I don't think punishment vengeance or deterrence should be considered at all. Obviously certain people are going to be irredeemable and should be kept in prison for the rest of their lives. But it shouldn't be because they 'deserve' it for whatever reason, but because they're likely to go back to crime on release. I think certain white collar criminals should be as likely to serve long sentences as people who commit armed robbery, depending on their motivation and background, etc.