Nah, that has been proven to not be true (at least in most cases).
What usually happens is a combination of various factors, money being one of them. And when money is part of it it usually psychologically functions as a proxy for whether your company/boss cares for you.
Most people want confirmation of their own beliefs about themselves -- they want the company/boss/coworkers to be showing respect and show that they value your work. People want to see that their work is accomplishing something and a lot of people can go to great lengths to lie to themselves that this is the case. And a lot of people also want progress, they want to see themselves doing new things, getting more responsibility, advancing their careers.
I hired and said goodbye to A LOT of software developers. And I do understand that it is difficult to get an honest, unbiased response when you ask them for the reasons for their decisions to leave.
But at the same time you get to experience trying to get people to stay and seeing what works and what does not. Giving raises works relatively rarely -- it only seems to delay. They are already discontent with their job and the higher salary only functions as a sort of gold handcuffs. After quarter century of doing this I literally am still to see a situation when a developer is offered a higher salary and suddenly becomes enthusiastic about their job to have a long fruitful career.
So what does work? Trying to find what causes them to be discontent in the first place and trying to address it. Do they feel they worked for too long in one project? Are they bored intellectually? Are they not getting along with their current boss? Changing the project without any raise is in my experience one of highest success rate things you can do in this situation. That success rate may not be very high (people tend to leave anyway) but at least I have a lot of good stories of people who changed teams and things clicked for them and they liked their new team. The only things that worked better in the past are changing the project WITH upgrade to the salary to reflect the market, and, for the ultimate highest employee-keeping potential - promotion to manager.
If people really did care mostly only about money, upping their salary should have greater success rate than moving them to another team and yet it is the opposite.
Now... this all assumes software developers and we know software developers are not exactly starving. If you are earning very little compared to your needs or when those needs grow suddenly people tend to really start paying way more attention to just monetary compensation.