> The aim is to produce a body of knowledge that will be useful to humanity.
There's no such consensus. Read Hardy's "A Mathematician's Apology" to get a better understanding.
Here's a quote which gives some idea of where Hardy was coming from: "I have never done anything 'useful'. No discovery of mine has made, or is likely to make, directly or indirectly, for good or ill, the least difference to the amenity of the world."
Hardy valued math for its beauty, elegance, and permanence, and he's far from the only mathematician who would push back on the idea that mathematics should be "useful to humanity", except perhaps in the sense that art is useful to humanity.
Did any mathematics done by G H Hardy turn out to be quite useful in the end?
Ironically of course the answer is yes.
The irony is his words just became AI training data to immortalize becoming useful through the point you just made, which is an asterisk on his name.