Humans don't have a ton of preferences for the electricity they consume or the water they drink, just that it exists. It's a commodity, so a good task for government. Housing is not an undifferentiated commodity and is subject to extreme variances in preference. Markets do differentiation and preference matching infinitely better.
Hence why Government housing always takes the form of a utilitarian blight on the community with giant towers of tiny apartments with tiny windows...doesn't matter if its communist Russia or the richest capitalist city on earth (NYC), all government housing results in the same outcome.
Assuming someone will chime in with some "halo" government housing project in the nordics that represents like 0.01% of the government stock there but socialists will use as propaganda. However, it's important to remember these are not cherry picked examples, they are median examples:
[1] NYC government housing: https://www.brickunderground.com/sites/default/files/styles/...
[2] Russian government housing: https://i.redd.it/twz37r739xse1.jpeg
To be sure, are you asking if society does better when its people are homed vs. homeless? Because that seems like a question with an obviously-yes answer.
And who pays for that? The whole society: Either the government raises taxes, gets more in debt, or they print more money driving inflation up.
The most basic commodity, food, is a great example. The moment the government has ever step into controlling production of food, we’ve only seen subpar performance and starving people as a consequence. Ultimately killing millions (USRR, China, Korea…)
You might be surprised to hear how heavily government directed and subsidized food production is in the USA.
There's an alternative approach which mirrors the public healthcare concept of "public option". Instead of restricting government housing to means tested individuals or specific low income populations, you develop a public competitor to drive prices down and to eat costs in regions where housing is needed but the economics just don't make sense yet.
i.e. the US Postal Service model. It works extraordinarily well as long as you don't repeatedly capture and handicap the org/agency (like has been done to the USPS). And even with the USPS despite being severely handicapped it still provides immense value by driving prices down while maintaining the essential service of last mile delivery.
A similar approach could be envisioned for a public construction agency.
When the options ar homelessness or subsidized housing, subsidized housing is absolutely the best option, which is backed up by decades of data.
If the government just went on a building binge of housing to be sold at market rate, or even set an upper bound before qualifying to buy them at a middle class income, it’d work out fine. That’s basically how Singapore does it only they couple it with somewhat aggressive policies to encourage people to downsize their living situations once they’re empty nesting to free up family dwellings for people with families. We probably wouldn’t need to do that second part since we’re not a claustrophobic island, and could just count on natural turnover.