Controlling spam inside a closed network is drastically easier than controlling spam in an open network, because in a closed network you have lots of ways to make bans stick, whereas in an open network you really can't. Faced with the choice of building a massive Gmail style heuristic spam filter in which basically all the messages it was processing would be spam, or, just turning off federation, they went for the latter. It was probably the right call. Very few people even noticed, let alone cared. The idea of an SMTP-style global network of federated chat servers was dead by that point.
Google was kicked by the other servers out of federation due to their abandonment way before Google turned it off. And it was always flacky to begin with, specially since they also started dropping 3rd party clients (and for that you can't blame spam...).
And even if one argues that Google ignored federation because of spam and/or low usage, OP's claim that they did that "for their own advantage, making the world poorer" would still be valid.
I'm not saying they didn't have spam problems, but that's the kind of thing they certainly had resources to solve. They already had such systems due to Gmail, and even independent XMPP operators have a pretty good handle on XMPP spam these days without even a fraction of the resources available to Google. It was more a matter of priorities du jour for the company.
Independent XMPP operators don't have anywhere near the spam problems Google has/had. They're just far less appealing targets.
All of these companies chose to kill federation for their own advantage, making the world poorer.