First, housing in SF is insane. I have seen lots of articles about how bad it is and that $50k or even $100k is considered "low income" in these parts.
Second, the weather in the Bay Area is very homeless-friendly. If you need to sleep outside year-round, it is best to be someplace where you will neither die from the heat in summer nor from the freezing cold in winter.
Third, homelessness is on the rise nationwide. Homeless people can relocate relatively easily due to not having to give notice at their apartment and having lost most or all of their material possessions. So, the odds are good that some people are simply coming out here for the weather.
Fourth, big cities like SF tend to have more services for the homeless. There are meal kitchens and the like. If you are completely destitute, you go to where you can get free meals and other services. I know because that is exactly why I went to downtown San Diego for six months as a homeless person. I left and went elsewhere when I was no longer outright destitute and did not need access to things like soup kitchens to have any hope of surviving.
So, I think if you want to solve homelessness in SF, you need to work on homelessness across the nation.