I mean, in real life it's a combination of both. Some money is for math as an exploration of our world that will never pay off. Some money is learning things that may pay off long after we're dead (planting trees so our great grandchildren have shade). Some money is for solving problems right now.

Getting funding can be quite difficult at times, so you'll see some portion of researchers (or mathematicians in this case) take the dollars they can get.