You might have come across some of your friends telling you this or you might have experienced things such as when you do good you sometimes experience unfavorable things happening to you instead?
When things like this happens, our first reaction is to question if we should continue doing good. It is just a normal reaction but if you think deeper the experience has a whole lot more meaning.
For every action that we undertake there is a cause and effect. So if you did something good and something unfavorable happens to you it is actually your Karma ripening. If you have not done anything good to receive any good merits would your Karma start to ripen? If it ripens and something unfavorable happens to you, you should actually learn to accept it, at least you have the opportunity to redeem some of your bad Karma that began to ripen because of the good merits that you have done. If those Karma did not surface, it would have followed you to a lower realm and that would be a much harsher way to deal with it.
Good merits and Bad merits is an entity by its own, they will somehow ripen when the time is right. If a bowl is filled with chocolates and stones, isn’t it better to remove all the stones first before you start eating the chocolates ?
So when you do good and something not so favourable happens to you, look at it in a positive perspective. The more bad karma you managed to clear in this life the better your life will be next time.