SF attracts homeless from all over the US, given its mild weather (great for living outside) and generous social services. It has been like that forever also, you can watch old movies from the 1920s about hobos jumping trains to get to SF (or LA, or Seattle, or Portland, or even Vancouver BC, choose any of the west coast cities, all for similar reasons).
People have freedom of movement in the USA, and they mostly take advantage of it.
> Maybe it’s not capitalism at fault here but a government that is unwilling or unable to supply standard social safety nets like homeless shelters and addiction therapy.
The issue is then how do you prevent one locality from having their resources swamped fixing what is really a national problem. SF can't fix the nations problems, so its voters/tax payers get jaded really quickly.