Some people do in fact do it for improving understanding and benefiting people. You’re rather showing your own worldview. I’ve met mathematicians who hold the view that the work they do is for the good of the world. Waking up everyday for that purpose is now a change of goal posts, pure mathematics as a field is what we were discussing, not the motivation mathematicians have in their daily lives to continue working in their field; I doubt anybody today can say they have the same motivation every day to go to work other than survival.