That said, this might change if remote work becomes a lot more common, and we might see a big flattening of salaries. Bad for SF real estate prices (and for high earners in those companies in general), since people in those HCOL markets will suddenly be competing a lot more directly with workers from elsewhere, modulo language skills, ease of scheduling, cultural fit, etc.
Basically companies base their compensation bands on the 50-90th percentile what the market is. People are also anchored their previous compensation, it's hard to get people to accept drastically lower compensation even if you think they are overpaid in their current job.
So it all comes down to finding a compensation that both parties are willing to engage in at (the market). The market is still not fully liquid, uniform or not all talent is the same so the pay differs in different markets.
You could obviously game this too by saying to pay what people are they are "worth" but you just happen value SF experience more than other experience, essentially.