Before prison, the common practice in antiquity was to exile people. Which has the exact same effect as prison: to remove people from everyday society. That's why the primary goal of prison is to achieve the same thing: removal of individuals who cause harm (whether they are actually doing harm is a different discussion).
If you want to reeducate people, I'm not sure prison is the right place to do so.