People write textbooks for a variety of reasons. Money is only one and for most authors the monetary rewards are modest (very modest). There are exceptions. I once (more than 35 years ago) had a colleague who was a millionaire based on publishing math books. Economics texts can earn astronomical amounts of money for an author. But these are mostly elementary texts, because such things have a wide potential audience. The first Calculus course is taught to millions of students every year.
But advanced material, such as Hatcher's books, have a much smaller potential audience. They are therefore much more expensive (per copy) to produce since the returns are small.
Moreover textbooks seem to have a limited lifetime, though some old classic math books are, IMO, priceless.
But there are other reasons to publish books. One is that a person wants to teach a course in a certain way and doesn't find a suitable book for their students. Another reason is reputation. One way to earn tenure and advance in rank is to publish books.
Another reason is just that a person is interested in a topic and wants to bring their ideas together and share them.
In the case of Hatcher, it is a combination of all these things. I suspect that money was the smaller part of his equation, since he was paid pretty well and is now retired. His books have been harder to find in print, due to financial calculations from the publisher, so he decided to share them. He feels good about what he has done and it is reward enough. Especially for someone who has had a successful career and is retired. He probably has a substantial pension, making book revenues immaterial. That is also my own experience, though I use a different model that keeps the price per copy very modest, but not zero.
But, publishing printed materials is an expensive operation if you want quality. The few books I've done with established publishers, such as Springer, have taken a long time to produce with many people involved, just to get to the point where it makes sense to actually cut the trees to produce the paper and print the book, never mind the distribution costs of getting it into your hands. Everyone along the way has a right to be compensated fairly for their efforts.
Some people are willing and able to make the results of their efforts a gift. I celebrate that and wish it were possible for more people to do so as well.
But, if you think of it as paying it forward, then taking the gift puts an obligation on you to pay it back in the future. But pay it back not to the authors themselves, and not necessarily in money, but with contributions of some form to the community at large.