I think a great example of this is cryptography. The foundations of it come from number theory (prime numbers, modular arithmetic, elliptic curves), but the subject of number theory, before the advent of computing, was possibly the most useless kinds of mathematical 'art' that could have existed. I imagine it was the mathematical equivalent of frolicking in the fields.
Mathematicians explored Fermat's little theorem starting in 1640, but they didn't do it because they knew it'd be useful several hundred years later in RSA. They did it simply because math is worth exploring in itself.
Even if you don't subscribe to the idea that we should pursue math for math's sake, history shows us that it's very difficult to know what parts of math will be useful to humanity, especially hundreds of years later. Since people work best on what they find interesting, mathematicians should continue exploring the topics that most interest them, because we really can't say with any certainty what will prove useful (or even essential) to future generations.