What do mathematics researchers do if they aren't good? I am a high school student so I don't know much about academia, but I would like to clear up some confusion I have over research in mathematics. Please excuse my naivite/ignorance on this topic. 

I get the impression that mathematics research at the graduate and post-doc level is hard. It could take months of getting nowhere before you make some progress on a problem, and depending on how good you are and the difficulty level of the problem, you could go an entire year without publishing any papers. I get the impression that proving interesting or important results is even harder and is really only for the best - the real mathematicians. By important I mean results that will be noticeably useful to other researchers in the field. 

I am guessing that not every person who gets a PhD and goes into research is good enough to prove interesting or important results, and I'm guessing that the percentage of PhD's who go into research and who will become successful mathematicians is less than 50%. I'm wondering what do these people do? If they can't publish enough papers and they aren't successful in solving any problems, they can't continue like this forever right? I mean at some point the university they are employed by will reject them? Do these people leave academia entirely and go into industry, or switch fields into physics or something like that? 

Please let me know if my understanding is correct.
Many people who complete PhD's in mathematics end up leaving academia within a few years after completing the degree.  Many others settle into teaching oriented positions at community colleges, four year colleges and regional comprehensive universities where they typically end up publishing little or no research.  A small percentage of all PhD's in mathematics end up as tenured faculty in research universities (much less than 20%) and even among these mathematicians at research universities there is huge variability in research productivity (e.g. as measured by papers published per year) and impact (e.g. as measured by citations of these papers.)