If you think practically, then yes you're right in some way but I guarantee you the peace of mind you attain after doing good in the worst situations is GOLD.
Would you still be a good person if the risk of being good could hurt you?
Being good in today's era comes with consequences and if you choose to be a good person you have to bear them. So, either be a good person and get hurt or be a self-centered one and remain unharmed.