I think the point is that it is cheaper to educate these people once for three or four years so they can get decent jobs and make a positive contribution to society, than it is to incarcerate them repeatedly for the rest of their lives.
People who have a low quality of life don't have much to lose by committing crimes (low opportunity cost). They either succeed with the crime and improve their shitty quality of life a little, or they get caught and given free accommodation, food, clothing, utilities, etc.
But if we give these people an education, then they can get a decent job, buy a car, find a partner, get a mortgage, and suddenly they feel like they have something to lose if they were incarcerated for a crime (high opportunity cost). It's the carrot approach that keeps the middle class in check.
Of course some people are a hopeless cause, so we keep running prisons as a last resort for such people, but such a scheme might just end up being cheaper in the long run.