Its not an ideal system, but there's a certain sensibility to it that stabilizes society. If people saw those that go to jail, come out better persons. They might get the idea that the criminal is a leadership figure, or that they too might become better persons after experimenting with crime.
I'm a strong believer in prison reform, and treating criminals as victims of the difficult choices life offers you. It shouldn't be the accepted standard to put them in a cage and forget they exist, we need to show them the flaws of their moral system: we need to preach to them until they concede the errors of their ways and show meekness.