means that
acts of kindness or helpfulness sometimes bring unexpected criticism, trouble or inconvenience to the person who performs them. The saying is ironic, not a rule of moral conduct.
Imagine a case where no good deed goes unrewarded; then “No good deed goes unpunished” fits well.