I have recently written a textbook, and I have written it for a series that I know will get widely pirated, because the pages are A4 sized and photocopy really well and it will appear as a torrent quite quickly.
I will not make a lot of money from the book - probably $5k per edition, but writing it will enable me to share my vision with a lot of people, and I regard that as a privilege. The more it is pirated, the more it will help my career.