Why do math/physics professors publish textbooks? Does it help their tenure case to write an expository textbook? I'd be surprised if it does, seeing as writing a textbook on, say, quantum mechanics, is not original scholarly work. 

So why would a professor, say an aspiring full professor, write a textbook? Money?
Does it help their tenure case to write an expository textbook?


While I cannot speak for math or physics, in many of the biological and medical sciences, it would likely actively hurt your tenure case. "Why did you spend your time writing a book instead of getting more grants/writing more papers?"


  So why would a professor, say an aspiring full professor, write a textbook?


There are a few reasons one might be interested in writing a textbook:


You have, effectively, already written one. Many professors, having taught a course for a number of years, have accumulated a body of lecture notes, slide figures, exam questions, etc. that might be the foundation for a decent text on the subject. Writing a book is a way to get "credit" for all that.
There is no book on the subject you're writing, and you want one.
Writing a well-regarded textbook is a means to influence the direction of the field. For example, if you wanted to push a particular perspective on how one should approach the field, etc. writing a textbook on the topic is a way to do that. Again, not in math/physics, but in my field people are writing textbooks with either a causal inference or systems science bent to them to try to help push those methods forward.
Simple desire. Books are neat. They feel important. Many people are rather fond of them as objects. Seeing your name, and your thoughts, in a proper book on a shelf is an appealing concept. That may be enough.