What does Matthew 6:5 mean?
Jesus is warning His listeners not to be hypocrites when it comes to doing good (Matthew 6:1–4). He has in mind Israel's religious leaders (Matthew 5:20). He has already shown that their emphasis on outward actions and not inner attitudes leads to a false spirituality. The righteousness God desires starts in the heart. Thoughts and attitudes are as much a part of righteousness as words and deeds; this was a major theme of chapter 5. Doing good in ways that cause people to praise God is a good thing (Matthew 5:16). What's not good is giving with a motive of earning worldly praise (Matthew 6:1). If necessary, Jesus says to hide your giving, so nobody knows but you. Then you can be sure that your only motive is pure devotion to God (Matthew 6:2–4).Keeping with the same theme, Jesus applies the idea of motivation to public prayer. Those looking to announce their own spirituality loved to pray out loud and loudly both on the street and in the synagogue. While this might not be as common in the modern era, it is still possible to pray with an inappropriate concern for how we look or sound to other people.
As with selfishly motivated charity, Jesus says those who pray "for show" have received all the reward they're going to get. The Father will not honor acts of spiritual pride disguised as acts of righteousness. Even in prayer, one cannot "do good" for the wrong reasons.