A secondary reason is touched upon here, but if the perpetrator of crime is not punished, only isolated comfortably, committing crime becomes attractive in and of itself to the portion of people who are currently less comfortable than prisoners. That's why the treatment of prisoners is a great metric for the quality of a society: it sets a baseline for the way non-prisoners are treated. You can't give prisoners free, high-quality education, no matter how helpful it would be to prevent crime after they're released, if you're not giving it to the general public, or else the general public would commit crimes to be educated.