But, there's nothing quite as satisfying as setting out to do something really difficult and seeing it come together. And unlike most other things in your career where you're part of a team and sharing your success, a book basically rests solely on your shoulders. So it's easy to point to it and truthfully say "I did that".
Plus, it turned me into a really good writer.
Aside from that bit of data, there is one definite advantage to writing. The process of writing a book is a great way to learn more and get better at explaining what you know. This is a double edged sword because if you spend six months on a first draft, you will likely see a major difference in quality between the first section you wrote and the last.
You may make some money, but you’ll almost certainly learn something.
I think in general the answers might be something like ‘look for clues’ or ‘try to get feedback on whether the idea is good early’ but I also think a lot of the time it’s just people writing books they want to write or that they guess people will be interested in. But I’m definitely guessing and I don’t really know.