A cautionary epigram, usually directed at the naive. There are any number of reasons why a good deed could carry evil back upon the head of its perpetrator, but the essential lesson is that goodness without direction can be as bad as intentional evil. In the words of the Old Testament prophet, Karl Marx, "The road to hell is paved with good intentions."

Certainly a strong soul could decide to act nobly no matter what the consequences; accept that even with the highest motives, mistakes can be made and people hurt; give of oneself without thought of reward. Yes, it could happen. But that is miles away from supposing that being good affords some sort of protection... oh, dear.