Your fantasy works great for normal people who for reasons can't afford a house but overall treat things well. It doesn't work for someone who has mental issues which sometimes turn violent. (often hard drugs are a root cause - but there are some born this way through no fault of anyone.) I don't know what to do about those but it is a real problem.
In the past society put them in institutions, but that has been out since the 1960s or before - for good reason. Institutions invite by nature invite the staff to abuse the people. Homeless is better than institutions were (even including cases of someone freezing to death). From what I know of prisons I can tell you we have not solved this human nature problem and so I cannot support going back to institutions.