Laying up your treasure in heaven and not upon earth seems like a fitting summary to Jesus' promise--which he emphasizes three times in this chapter--that "your Father who sees in secret will repay you." Up until now Jesus has been exhorting us to forsake the praise of men. Don't sound a trumpet as you dump your gift into the temple treasury, or make a display of yourself on the street corner to say your prayers, or look haggard and miserable when you fast. Otherwise people will notice and reward you with their earthly praise.
Jesus must have religious leaders particularly in mind, because in the secular world you can't gain earthly treasure by showing everyone how awesome you are at praying, fasting and giving alms. Only someone who aspires to be a religious leader might be tempted to use pious hypocrisy as a means of obtaining the kind of material reward that moths and rust and thieves can prey upon. With all the spiritual charlatans who are profiting by preaching a false, fleshly gospel today, you don't have to look far to see the kind of person Jesus is talking about. Peddling the gospel for money is strongly condemned by the New Testament writers.
But aside from being a warning to church leaders, it can be an encouragement to the lay person who serves in obscurity. I think deep down a lot of regular church members feel like second class citizens of the kingdom because they aren't serving as one of the ordained leaders of the church. Like, maybe when we all get to heaven it will be all the pastors and elders and missionaries who get dealt the big juicy rewards while everyone else will have to be content receiving the consolation prize.
But this passage levels the playing field. What matters is where you are laying up your treasure and where your heart is. The less recognition you get in this life for doing good, the more your heavenly Father is obligated to "repay" you by rewarding you in heaven. This is essentially what it means to lay up treasure in heaven, which is why Jesus encourages secret piety. When I think about it, this principle can actually work against people who serve in high profile ministry capacities since many of them face greater temptations in desiring the praise of others, whereas the person who serves in obscurity may face fewer distractions. In that sense, perhaps being an unrecognized layperson is a blessing in disguise: the lack of praise you are getting in this life is laying away a storehouse full of treasure in the next.
It's interesting that Jesus says "where your treasure is, there will your heart be also." I guess if it were me, I would have put it the other way around: where your heart is, there will your treasure also be. The problem with my idea is that it's hard to know exactly where your heart's at, isn't it? Is my heart in heaven, or is my heart set on earth? So maybe Jesus is saying, lay up treasure in heaven, because the more you invest there, the more your heart will grow attached to the things of the next life. Having that stash of treasure up there will guarantee that your heart will become weaned away from this earth and increasingly crave the solid things of heaven.
What is this treasure? I don't know. Does it matter? It's better than anything earth has to offer. It's incorruptible, unbreakable, and worth all the sufferings you've ever been through. It has to do with receiving the praise of God, a special place of service in the kingdom, a seat at Jesus' banqueting table, an inheritance. Those are just metaphors that combine together into something wonderful beyond comprehension that I won't even attempt to describe.