Cost of living adjustments occur because companies can get away with it. That’s pretty much all there is to it. They have additional leverage when a potential employer wants to live in a particular location and that puts the potential employee at a disadvantage.
That said, I actually think most of these companies would prefer to pay everyone equally if they could get away with it as well, because ultimately they will cost the company less in labor. But they can’t at the moment. All the talent is concentrated in just a few spots and much of this talent does not want to move. In a hypothetical world where remote work really takes off, location will no longer matter. No company is going to pay someone twice as much just because they want to live in a nice location. It’s simply that this is what is required by companies at the present time to keep the employees that they value and have already invested in.
It would be interesting to run some simulations where you vary the desire of a workforce to work remotely and see how it changes the pay required for maximum talent retention. Since widespread remote work is new, we’re not anywhere near an equilibrium yet.