Ann is paid $170,000 in the Bay Area because that what all the other developers of her caliber are willing to exchange their time and expertise for.
A company would pay Ann $50,000 if it could. They only hire people who they think they will eventually make more from their labor than they will pay the person.
If you are Google, you will make roughly $1M per employee currently. For Software Developers that number is even higher, for Sr. Software Developers that number is even higher. The fact that how you get paid and how much value you generate don't have much of an effect on each other is basic capitalism.
What's smart is to be Ann, get a $170k salary and move to Costa Rica and keep the $170k because at the end of the day, she wouldn't have been hired if she didn't make more than $170k of value for the company.