It's to teach them that there is potentially a lot more to life than the way they have currently lived, that life can be awesome and show them some of the stuff they could attain if they change their ways, and they don't have to live the rest of their lives like they have been living up to now ... some of these people would have never in their lives seen anything but how cr&p it can be and literally don't know any better. This is to show them better.
There are many cases where it has worked. Sent a yob who never had a chance on a 3 week safari, and when he gets back he's been inspired and next thing he's working hard to achieve what he now knows is possible to achieve. Send an identical yob to prison for 6 weeks, at more cost, and he meets lots of criminals, and anyway he's already been to prison 7 times IT'S CLEARLY NOT WORKING!
MUCH, MUCH cheaper than putting him in and out of prison for the rest of his life.
Of course the daily mail amongst others gets an easy headline by dissing such schemes. And that somehow public flogging may inspire them to change their way of life instead. It is of course, rubbish. But easier for Johnny Thicko in the street to digest ..