Even in the same FAANG-companies, I am aware that there are people doing the same roles at the same level (and even sometimes in the same team) in London (a city was equivalent living costs as SF) who are paid significantly less than their Silicon Valley based colleagues.
I.e. all things being equal (same employer, same job, same level, same teams), people in SV get significantly more than people in other major cities (and it is not just like an extra couple of thousand, it is often like $150-200k vs $300-350k etc). I knew of someone who simply moved from SV to London (same team, same manager, same role, same level etc - just an office location change) who told me they got a 60% pay cut - i.e. the only variable that changed was location, everything else was the same.
The explanation given for these "discrepancies" are that the lower salary outside of SV is due to "market rate", i.e. that there are not enough other companies in e.g. London competing for talent to support higher market rates, and that the FAANG pays "at the top of the market rate", so that is why salaries are lower in London despite living costs being the same as SanFran.
$150-200k is still a fairly respectable salary in London by the way (London average is approx £39K/$51K), but you still have a near-zero chance of buying a nice house on that salary (you might afford an apartment out in the outskirts that is 40-60 minutes away by train from the office in center of the city)
A lot of commentators here are talking about the profitability-to-the-company of a single dev, or the opportunity cost a dev is missing when taking a full-time position vs starting their own business. I think if that were true, there wouldn't be such a wild variance based entirely on location. The simple reality for me is that companies just pay the smallest amount they can get away with, and it just happens that in SV that needs to be high because there are a lot of competing companies looking for staff.
I.e. supply and demand.