And it's not necessary a factory. It's not hard to create awful work environments.
Back in the 70's and prior, mental health facilities were barbaric. "One Flew Over the Cuckoo's Nest" brought to light these travesties, and many were shut down.
Later, republicans then shut down more by defunding as well. What effectively happens is people are shunted to other communities where better services are offered. Lookup "Greyhound therapy", where city govt's pay for bus service to 'somewhere else'.
Now, the primary caregiver is the penal system. And remember, we still do not have single-payer medical, so unemployed/homeless are still without.
Robert Kennedy even spoke spoke out in public against the facility (his sister suffered a bad lobotomy requiring full time care). Many kinds of institutions closed in the 1970's, and for good reasons.
With that said though, mentally ill homeless can be a challenging problem. Many of these ill "fell through the cracks", and even if a program was offered for them, they don't have the capability to seek out said program.
Mental health is a definite dark spot in America.
When they aren't able to work, it's usually because they're extremely disruptive, unable to cope in a work environment, and/or profoundly disabled, and volunteering in a soup kitchen/helping the community in lieu of "a job" probably isn't going to work out so well. It would be more of a burden and resource cost to have them monitored and supported than the benefit received by the organization. Instead, they go to day programs that have job training (if possible), therapy, and more one-on-one support in a dedicated environment. Volunteering is definitely available if they want to do that, and are able to, but it's not really a "oh, if they can't make money, we'll have them work for free" type of situation.
And, you know, of they are doing useful work, maybe they aren't relevantly "disabled" to deserve a lower wage
Realistically, for people with disabilities that aren't being able to be in the regular labor market, there are some societal useful things to do, like volunteering(say in a soup kitchen), helping their community,etc. Those are probably activities that wouldn't be done otherwise, carry a real sense of value, and usually in a custom fit environment.
That is the situation at least in enlightened places with decent government services. I'm not sure about the US.
I wouldn't want that to be replaced with people at the margin being exploited at a shitty factory , where the work is meaningless and often depression inducing, sometimes risky, etc.