Thank you. I get really tired of hearing people claim that professors are teaching out of their textbooks to make money. VERY FEW textbook authors make any real money, and none of them make much from their own classes.
Some, I'm sure, do it for an ego boost, but most people I know that teach out of their own textbook do it for completely honest reasons. They really think they know the best way to teach material and want to teach it that way. Often there is lots of nuance that they want to teach that isn't captured in any particular book.
If a professor honestly thinks they have the best way to teach some subject, they have to write a book. And, if they want that book adopted by others, they have to get the book published. While we have gone a long way with free textbooks on the web, the fact is that you're very unlikely to get that book adopted by others unless you have the publishing industry sending out representatives pushing your book. So -- while it may seem silly that professors don't give away their books given how little they make on them -- many use publishers because they honestly want the material to be taught in a better way.