There is more than one way to write a book. You can write it for artistic personal reasons and hope it sells. Or not. The reward is the process and any money earned is a bonus.
Or you can write a book with intent to make money. If you are doing this it’s a job or business that needs to be defined with a comprehensive business plan including marketing plan, distribution plan, etc... you could even hire a ghost writer to actually write it if you don’t like writing or aren’t very good at it.
Your odds of making money are much better in the second scenario. Your odds of really enjoying the process and having a cathartic moment is more likely with the first.
I have a friend who recently finished and self published his life’s work. The great American novel. He will probably not make money but it was important to him to complete it. Now he’s off to the next challenge after 10 years.
Another friend saw a need in the marketplace for information she possessed and made a plan, built up a social media following to promote her book in advance. Took time out of her work schedule to work on it. Hired a good editor and wrote her book in about 5-6 months. She made $7 million on it the first year and now enjoys annual income in the $10+ MM/year range and has quit her job to focus on building more revenue streams around the ideas in her book,
Obviously most writers fall somewhere in between.
Where you fall in the spectrum is entirely up to you.