The primary purpose of prison is neither punishment nor rehabilitation, but rather to protect the general public. Whether incarceration is the best approach to accomplish that goal is a separate issue, but the reality is there are a lot of dangerous and antisocial people who can't be running around loose.