Those who leave may not always be the best, but those are best will certainly leave. It makes no sense to Not switch jobs if you get higher salary and have capability to get it.
In tech industry where job hopping gives significantly greater raise than yearly increment, those who switch jobs get more exposure and better worldview. While those who stay get 1 year experience 10 times.
PS: Exceptions are always there