20 years ago when the first wave of outsourcing to India happened, a lot of the engineers there were not great. Nowadays there are amazing engineers in India also. They do know what they are worth though, so you cannot low ball them. But they are still working for quite a bit less than Bay Area folks.
That will only last so long until consumers reject the terrible quality and move on to another, higher quality competitor - so the wheel will continue to turn and high quality developers will still be hired to produce high quality work.
An Indian employee's salary being 1/5th of an American's, doesn't mean their cost to the company is only 1/5th. There is a general organizational/overhead cost to taking on more people. This cost, for one additional person, may be higher than even the American's salary