People don’t ever seem to realize that doing what’s right’s no guarantee against misfortune.
William McFee (1881-1966) English writer
Casuals of the Sea, Book 2, ch 6 (1916)
(Source)
Sometimes paraphrased "Doing what's right is no guarantee against misfortune."