A better solution is to provide them with shelter, community, mental help, education, and generally good care. This is actually even harder to do than just throwing houses at them.
But there is also merit to giving housing to people who are homeless but not mentally ill. Many European countries do this.