I guess it is good thing you have obviously not spent anytime in prison. The inmates run the prison, they determine who is safe or not, and they allow people to be hurt when they chose. Sometimes, the guards may intervene before something bad happens, but mostly they do not know what is about to happen. The government only manages who comes and goes, and government is in no way 100 percent in control of the place. Drugs, homosexuality, beatings, rapes, are just a few ways the inmates control what goes on. Guards are bystanders, and frankly, they are not paid enough to risk being hurt by intervening.
I am aware that inmates run prisons. That is the problem. A very ancient problem.
Hard labor at least can make prisoners economically productive and to worn out to start mischief.