I mean, there is so much overlooked here, I'm truly confused by this post.
The housing cost is very clearly related to the issues of homelessness. Of course it's not the only thing, but it's a significant factor.
Fix housing, provide housing for the mentally ill.
Voila! You no longer have mentally ill homeless people. Like, of course the system which doesn't support people until they're able to stand on their own legs results in people repeatedly falling over.
Fixing the mental illness epidemic is another problem, one which may require better policy around housing, food, mental health services, and taxation of the wealthy. Even then we may not have the tools to 'fix' all the people who've been broken by the current system, during the lifetime, because the human brain is so complex.
But if we fix these issues, the next generation wouldn't have so many mentally ill homeless people in the first place, and we'd have better tools in place to treat people before their mental illness spirals to the point where it's beyond our current mental health care industry's capability to treat.