It's absolutely not optimal, it's inefficient. Many companies have learned this, which is why you see things like "Unlimited Vacations! Free snacks! Company provided lunches!" etc, offered as perks.
For low-skill labor, there isn't much benefit in making employees lives overly comfortable, but it is worth it to invest in some basic amenities - easy access to clean restrooms, regular breaks, clean air, clean water, warmth. These are the basics.
In the case of these workers:
- Better dorms = good sleep/less sickness
- Decent food (without worms...) = less sickness/healthier employees
- Decent toilets = less sickness/reduced stress
All of these => happier, more energetic, and less distracted employees => more efficient work => more work gets done.
With the benefit of making your company look like a good place to work.