Our Savior here teaches the general principle that man must not engage in acts of "righteousness" in order to receive the attention and praise of other men. This truth is applied to three actions in this chapter: charitable deeds, praying, and fasting. These were three major areas in which the Pharisees of Jesus' day clearly manifested their hypocrisy and impure motives. True followers of the Lord must exceed their type of righteousness (Matt. 5:20).
Jesus declares that those who perform acts of righteousness in order to obtain praise from men will receive just that, the praise of men (cf. 6:2,5,16). They won't enjoy any spiritual benefit from the heavenly Father for those actions, though they could have. God will only reward acts of righteousness that result from proper motives. A good example of one doing a charitable deed with a proper motive can be seen in the parable of the good Samaritan (Luke 10:25-37). The Samaritan acted benevolently toward the man in need. Of course, had there been an audience when the priest or Levite went by, the man in need probably would have received help sooner!
Notice in Matthew 6:2 that Jesus uses the word when, not if - "When you do a charitable deed do not sound a trumpet before you as the hypocrites do" . Some believe that this practice of sounding a trumpet before doing a charitable deed was literally practiced; others understand the reference figuratively. In either case, the hypocrites of today don't blow literal trumpets to foretell of their acts of benevolence, yet they certainly do use methods to call attention to their generosity that they might receive personal glory.
When you do good for someone else, "do not let your left hand know what your right hand is doing" (Matt. 6:3). The idea here is that a Christian's generosity should be a natural part of his life. It should come so spontaneously, and with so little thought, that one part of the body should almost be able to engage in it without the other parts knowing. This figure of speech clearly forbids one from boasting about personal acts of goodness. This statement does not demand that good works be done secretly or that they cannot be made known by others (e.g., Mark 12:41-44; Acts 4:32-37; II Cor. 8:1-5). Jesus is not forbidding the publicity of good works; He is forbidding the attitude that desires publicity.
But Stephen, are you certain Jesus isn't teaching us to do all good deeds secretly? Yes, I am certain, in spite of the fact that the next verse mentions good deeds being done in secret and rewarded openly (Matt. 6:4). If one concludes that all good deeds must be done secretly, then he will contradict what our Lord taught earlier in Matthew 5:16 - "Let your light so shine before men, that they may see your good works and glorify your Father in heaven." A Christian's goal in life should be to work in such a way that others will not see him but his good deeds. That is what the focus should be on--the good deed--not the mortal man or woman doing good. This is the difference between "letting your light shine" and "shining your light."
Ultimately, one must desire that the praise be given to God for good works accomplished and not to one's self. Friends, do not rob God of the glory that is rightfully His by focusing your praise upon the creation rather than the Creator, and do not rob yourself of the "reward" that Almighty God has in store for you when you seek His approval rather than the glory of men.