To avoid this, companies use various tricks to fix wages such that they don't have to pay even the highest valued employees more than a fraction of the value they actually bring to the company, and thus can get away with huge profits.
To illustrate this with an extreme scenario, assume that all of Apple's work relied on a single engineer's designs. If Google and Apple were to compete on who can hire that engineer, Apple would be willing to pay almost all the way up to their entire revenue to that single engineer, as in this contrived scenario, if they lose him, they lose all of their revenue. So, Google and Apple would be racing to the bottom, offering ever more extravagant salaries to this magical engineer until they couldn't pay him and make a profit at all anymore.
So you pay them $3m a year? Now there's zero profit, so nothing to invest in expanding the team, improving your services services, hiring more developers, growing the businesses, funding new projects for that developer and all the other employees to work on. Oh, by the way you owe $20m to your investors that put down the capital to get the business off the ground in the first place. How are you going to pay them back? Also, maybe you could have hired another developer and they might have done just as good a job, which is also true of everyone else in the business.
Finally, if you do up the pay of the developer say $1m a year, what happens if the product gets eclipsed in the market or the developer moves on to another product nowhere near as profitable. Now they're working on something bringing in a lot less, but they're still costing you a million a year.
Even Facebook has had to lay people off when the market demand for $500k genius coders cooled a little recently
FAANG salaries and RSUs are pretty much the perfect compromise between labor and capital IMO. The only way I'd change things would be to move toward fewer hours per week, possibly with widespread fixed-bid consulting and health benefits not tied to employment
P.S. if it was a race to the bottom, consider that only 1.5% of the labor force works at minimum wage.