I think it's mainly a matter of training. People who want us to do things for them train us in responding to extrinsic motivation. That's not terrible; some amount of it makes the economy work, after all. But for me one of the essential characteristics of adulthood is deciding how to train ourselves. If you want, you can reconnect with your intrinsic motivations.
I don't think it's impossible for cash-maximizers to be good developers, but I do think it's hard. A lot of software is essentially a long-term investment, so the short-term thinking of people hustling for a buck works against it. More than once I've had to clean up code bases put together by contractors who were clearly in it for the money and it showed in their work. There might be some theoretical way to bridge the long-term needs via a complicated short-term incentive structure, but I doubt it. It's too prone to things like the "code me a new minivan" problem: https://english.stackexchange.com/questions/488178/what-does...
Don't get me wrong, I am in it for the money in the sense that I need a proper salary but I couldn't care less about a 'bonus' being dangled in front of me and putting metrics in place that I'm supposed to hit to get a larger or smaller raise and percentage of the measly bonus (and no, making the bonus larger doesn't make it better. Makes it worse).
I do my best every day just because I enjoy my job. I won't try to do it better because of some metric someone is judging me on. I might actually do a worse job if I find my employer trying to use these metrics to deny me proper raises. Worse in the sense that you will probably see the metric reached. Actual output or overall results for the company will suffer.