It's because when you're locked up and immobile for countless hours and days at a time, it can get to you. So working out releases the pent up frustration and releases energy (i would say a good 70% of inmates are ADD too, so sitting still is hard for them). Also, everybody needs to feel some sort of accomplishment in life... whether it is family life, professional success, or athletic ability. If they're not allowed to work out, these individuals would be occupying the 2-3 free hours they have a day with something more destructful than working out.
And there is ABSOLUTELY NO CORRELATION between size (and working out) and violence... and infact allowing inmates to work out favors reoffending numbers (they reoffend less). As for my first claim, whether you're 300lbs or 150lbs makes no difference in jail. Fights rarely happen on a one-on-one basis, or without weapons... or are fairly fought with both sides knowing a fight will be starting. When you're getting jumped by 5 people with shanks, even if they were 3 foot midgets and you were 7 foot of pure muscle, you're going down.
And it does favor in rehabilatation. It gives them something to do, and it gives them something to strive for. People need to feel good, or a sense of accomplishment, and some do it through working out. If you ask the average guard whether they favor taking out weights or leaving them in, they'll tell you leaving them in is much preferred. Which would you rather be more worried if you were a guard? 20 people working out in the yard, pushing one another to lift the extra few reps... or those same 20 individuals scheming in a corner, whispering and passing things around?