Put differently, a tremendous number of people are willing to put up with SF, warts and all, rather than move somewhere else. It must be an amazing place to live.
SF has a lot of turnover, but the few studies I've seen say it's not particularly high by US standards. Nashville, for one, is higher. (Notably this study is by MSA so it wouldn't consider someone moving from SF to say, Burlingame a departure.) https://www.abodo.com/blog/so-long-to-the-city/
You're right about being able to enjoy the city in many ways. I regularly enjoy it at my leisure, it is 45min door-to-door Bart ride away, and relatively cheap to Uber/Lyft back at any time (Compared to the premium of actually living there).