The opportunity cost of those individuals educating exceptionally intelligent students to specialize in this particular blind alley is even greater.
The fact is there just aren't that many people out there interested in string theory for you to get up in arms about. People don't complain nearly as much about mathematicians, who spend their time on much less practical areas of endeavor.
Frankly, the fact that some people get to make their living working on marginally-productive things that they like makes me feel a bit warm and fuzzy inside, in a way not unlike the experience I get giving my cat cat food and a place to sleep.
Otoh: very possible their work produced spin-offs that were useful in other fields (math advances, thought experiments, practical research tools & equipment, people in other fields having a look at their work from a different angle, etc)
AND having bright people chew on a subject for decades & come up (mostly) empty, is a good hint there's nothing there. 'Unknown' vs. 'we've tried hard & not found much' is a useful result by itself. Think of it as reducing the search space.
Personally I know many people who abandoned Physics to reinvent themselves as data scientists. Good for them that they were able to re-purpose their training; that doesn’t mean physics training is the best way to become a data scientist. My bias is that quantitative social science is a better route, although some of what it gains from focusing on people is often lost through less rigorous mathematics and software development requirements.