Mark Twain stepped up and paid Grant to write his memoirs, giving fierce purpose to this warriors last days and peace of mind for leaving his wife with a means of support. Grants memoirs were a huge success and ultimately resulted in sales of $12 million( in current dollars)
It wasn't the Grant autobiography that financially hit Twain, it was the Sherman memoire that he published later. That was nowhere near the success that Grant's memoires were and that's where Twain lost money.