Why spend so much time and money to build AIs to play games?
In the book Artificial Intelligence: A Modern Approach (section 5.7, p. 185), Russell and Norvig write

In 1965, the Russian mathematician Alexander Kronrod called chess &quot;the Drosophila of artificial intelligence.&quot; John McCarthy disagrees: whereas geneticists use fruit flies to make discoveries that apply to biology more broadly, AI has used chess to do the equivalent of breeding very fast fruit flies. Perhaps a better analogy is that chess is to AI as Grand Prix motor racing is to the car industry: state-of-the-art game programs are blindingly fast, highly optimized machines that incorporate the latest engineering advances, but they aren't much use for doing the shopping or driving off-road. Nonetheless, racing and game-playing generate excitement and a steady stream of innovations that have been adopted by the wider
community

So, although these games (like Chess, Go, and Bridge) may not apparently be useful/beneficial to many people, the AI programs developed to play them have introduced/included concepts/techniques, like null move heuristics, futility pruning, combinatorial game theory, finessing and squeezing or meta-reasoning, which can potentially be useful to a wider spectrum of Computer Science (and not just Artificial Intelligence).
You can see it similar to space missions of NASA, ISRO, JAXA and other space agencies. All these missions don't seem to have a direct benefit to citizens, but have many indirect benefits. They pave the way for technological innovations (GPS, 3D printing, car crash technology, clean energy, LED), the creation of jobs, etc. Advance storms, hurricane detection is the output of space exploration, which has saved millions of lives worldwide.
AI in games has not just helped to develop the software but hardware also. Many innovations have been seen to produce highly optimised and powerful hardware.