The importance of credentials in pursuing an academic career in pure mathematics
First, the statement that your research is the most important factor only applies to research universities.  Other academic institutions have, for good reason, other important criteria.

Second, the first thing you should understand about academic hiring is that the hiring committee is unable to evaluate with a high degree of accuracy your research.  The error bars on the evaluation of your research are very large, and, particularly for more junior mathematicians, the noise can be almost as big as the signal.

Third, for junior mathematicians, a significant portion of the evaluation of your research comes from your letters of recommendation.  The quality and significance of your publications is much more important than the quantity, and we all know the journal reviewing system is very noisy, with a very large difference between the best and worst papers in a given journal.  Furthermore, your most significant work may not even have had the time to go through the peer review process.  You might think that the committee could try to directly evaluate your work, but in almost all cases, no one on the committee will have the expertise to do so, and in the remaining cases, only one person on the committee will, and they still have to convince everyone else.

Now to actually saying something about your question:

The fame of your recommenders is generally thought to be a noise reducing factor in evaluating your letters.  If a mediocre mathematician thinks you are good, who knows?  They aren't good themselves, so what do they know about being good or not?  If a well-known outstanding mathematician has worked with you and thinks you are good, then it seems more likely that you are actually good.  (In reality, I'm not sure how well ability in mathematics correlates with ability to judge mathematical ability in others, but I'm talking about how search committees tend to think.  There is at least some positive correlation, in that people who aren't mathematicians almost certainly don't have anything useful to say first hand.)

The places you do your PhD and postdoc(s) also likely put some floor on your ability, so they are also noise reducing factors.

Generally speaking, noise reduction on the bottom end helps your candidacy.  So going to a strong department and having a well known advisor doesn't just make you a stronger mathematician; it also makes you look like a stronger mathematician, or, at least, look less likely to be merely average or good.

On the other hand, search committees also recognize that people who went to less prestigious departments and had less capable advisors have had less opportunity, and more of their success can be attributed to them alone.  This might lead the committee to think the candidate is more likely to be successful in the future.  This means someone from a weaker program who can be a convincingly strong candidate might have an advantage.