What are prisons supposed to do?

Explain whether you think prisons should be primarily focused on keeping people locked away from society so they don't hurt others, whether prisons are places prisoners are supposed to be educated, or if they're places for rehabilitating people back into society?

How well do they do what they're supposed to do?

Do prisons do anything well even if they don't do what we want them to do?