> maybe I'm not imaginative enough, but I can't figure out
> why such awful conditions were built in the first place.
For somebody who is a high escape, high assassination or generally high risk. Somebody with enough money for example could arrange for an escape attempt at the court itself.
Unfortunately it's also used for anybody who acts "against the state", i.e. whistleblowers. Such cases do not occur without consent from high levels of government.