Unless you have better tools for locating the oil, that's not a bad strategy.
A crucial difference between digging for oil and doing math, however, is the nature of the externalities. In either case, you're burning some work that could be spent somewhere better, but with oil you're left with a hole that you probably want not to be there and there's no good way to put it back. In both drilling and math, "drilling" helps us refine our methods. In the case of math exploring more of the ramifications of our axioms also helps raise our confidence that they're not subtly inconsistent.
And of course, math is generally less expensive than an oil well.
I don't know where the cost-benefit analysis puts work on math when we don't yet see practical application. And I think that's often over-romanticized. However, I do think there are a lot of reasons we should expect the analysis to come out more favorably than for drilling random holes.
That's like saying that we should randomly start drilling holes in the ground because sometimes we will strike oil.
people arguing for it usually ignore the silent evidence of research that lead nowhere and also, more importantly, the potential research accomplishments those people could have acheived if guided to work on different problems.