I try to look at systems level more than blaming certain individuals. I'm sure a lot of engineers working on Google X projects honest to God cared deeply about the specific problem they were tackling. My own wife was once pretty close to taking a job there. But unless they're going to donate labor by working for free, they can't fund the projects themselves. The company has to be willing to lose money on most if not all of their work. I guess that worked for a while when ads were so profitable and no one else did them well enough. I may be misremembering my history, but as far as I understood, Bell Labs
had to do this kind of public good work as a condition of being granted a national monopoly.
At the cultural level, though, during periods like the space race and cold war, there seemed to be a national zeitgeist such that companies, their owners, their directors, were all willing to sacrifice some profit to serve a common national mission. Maybe it was just the fact that the CEOs had grown up in a time when food was rationed and factories were ordered by federal fiat to produce war materiel.
I don't actually think this type of culture is completely dead, for what it's worth. But it's not exactly in vogue. I personally work in defense, I served in the Army, and I make more than enough money but quite a bit less than Netflix likely would have paid me, but I work on products that serve US strategic interests. Entire companies exist explicitly for this purpose, but they're not Google scale and never will be. I don't think very many people on Hacker News would even consider this good, though. Witness the backlash to OpenAI even being willing to work on military applications at all. The readership is so cynical that they can't imagine a military serving any purpose aside from valueless destruction. In the 20th century when militaries saved the world from German and Japanese conquest and mass genocide, that kind of thinking was a lot less prevalent.
I also don't think these are the only two options, either. People can also be motivated purely by the science itself or by the global wellbeing of all mankind. I just don't know that, historically speaking, those bring large-scale resource mobilization to bear quite as well as getting rich and ensuring the continued strategic dominance of a way of life represented by a country of birth you deeply believe in. As people come to believe less and less in their own countries, we seem to be left mostly with getting rich as the only viable option.