When people come out of prison, they need a bed to sleep on and food in their stomachs, and they will find those things one way or another. Absent the means to achieve those goals legally, the only alternative is returning to a life of crime. So, really, the choice is either rehabilitation or recidivism. Recidivism comes with a bunch of costs to society, so rehabilitation is ultimately for society's benefit.
(I would argue that retribution has no place in the justice system, but that's a discussion for another day)
(I would argue that retribution has no place in the justice system, but that's a discussion for another day)