Each major section of Matthew 6 (the second of the three chapters relating the Sermon on the Mount) contrasts earthly and heavenly rewards. The unregenerate are known for their pursuit of earthly treasures and earthly rewards. Kingdom citizens are notable for their trust in God to provide earthly needs and their pursuit of God’s heavenly treasures. The Father who sees in secret will reward those who give, pray, and fast for His eyes only.
It rubs a good Protestant the wrong way to think that heavenly reward comes to those who do good, but it seems quite clear that Jesus is instructing His followers to do right in order to seek rewards from God.
R.T. France makes an apt comment on this matter, however, bringing in another passage from Matthew:
The verb “store up for yourselves” (literally “make a treasure for yourselves”) might suggest that these heavenly treasures are to be earned by the disciples’ own efforts, and the frequent language of “reward” in this gospel easily conveys the same impression…; in 19:21 it is by giving to the poor that “a treasure in heaven” is to be secured; in 19:29 eternal life is spoken of as compensation for earthly losses, and in 25:21, 23, 34, 46 the heavenly rewards are directly linked to the disciples’ use of earthly opportunities. But while the theme of reward is important in this gospel, we must remind ourselves again that in the parable which most directly addresses the issue (20:1–15 [the laborers in the vineyard]) there is a deliberate discrepancy between the effort expended and the recompense received: God does not leave anyone unfairly treated, but his grace is not limited to human deserving. In a kingdom in which the first are last and the last first (19:30; 20:16) there is no room for computing one’s “treasures in heaven” on the basis of earthly effort. Those treasures are “stored up” not by performing meritorious acts (and certainly not only by alms-giving) but by belonging to and living by the priorities of the kingdom of heaven.
R. T. France, The Gospel of Matthew, NICNT (Grand Rapids: Eerdmans, 2007), 259.
I found that genuinely helpful—using the Bible to answer a theological question rather than merely pontificating.