What does Matthew 6:1 mean?
So far in this Sermon on the Mount (Matthew 5:1–2), Jesus has taught that righteousness includes a person's heart—their thoughts and attitudes—as much as by their outward actions. Here, He begins to show that our inner person, including our motivations, is actually more important than actions. His message is not that what we do is unimportant, but that improper motives turn otherwise good deeds into selfishness.One great temptation of living under the Law and the Prophets, at this moment in Israel's history, was serving spiritual pride instead of serving God with pure devotion. This is still a challenge for many believers; the approval of other people is extremely tempting. Jesus warns His audience not to expect any heavenly reward, for even the most profound acts, if the motive behind those acts was simply to be seen by others (Matthew 6:2).
This statement in no way contradicts Jesus' recent command to "let your light shine before others, so that they may see your good works…" (Matthew 5:16), since Jesus is speaking of two different motivations. Good works ought to be visible and public if and when that publicity primarily serves to "…give glory to your Father who is in heaven." Doing good such that others believe God is good is righteous. Doing good such that others think we are good is arrogance.
The Father does indeed reward His people in heaven for "practicing righteousness" in the ways Jesus is teaching. He does not reward behavior done to gain the praise and admiration of others.