"‘You are the salt of the earth; but if salt has lost its taste, how can its saltiness be restored? It is no longer good for anything, but is thrown out and trampled under foot.
‘You are the light of the world. A city built on a hill cannot be hidden. No one after lighting a lamp puts it under the bushel basket, but on the lamp-stand, and it gives light to all in the house. In
the same way, let your light shine before others, so that they may see
your good works and give glory to your Father in heaven." (Matthew 5:13-16)
Right after the beatitudes, but before he gives his antitheses ("you have heard it said...but I say" statements) there is this interesting passage here. What is its role structurally? I think the answer is, after giving the blessings, Jesus is trying to explain to them the context of what he is about to give them. The explanation for their calling to holiness that they're going to receive (cf. Mt 5:48) is one both of function and of identity. This is a pure metaphor that Jesus uses, in that he says that the people listening are the salt of the earth and the light of the world; it is their identity. They are identified primarily by their function - the functions that light and salt have.
Before I get to the very important question of what those functions are, one must first ask "who are the people that are listening?" In verses 1-2 of chapter 5 we read that:
"Seeing the crowds, he went up on the mountain and when he sat down his disciples came to him. And he opened his mouth and taught them, saying:" (Matthew 5:1-2)
It is clear that his sermon is in response to the crowds, but the disciples are the closest ones nonetheless. I contend that the sermon on the mount in general, but this statement of vocation in particular, is directed at the Church. Although the foundation of the Church in St Matthew's gospel is not going to be until chapter 16, I think that this sermon is directed towards this proto-church in a literary sense, even though anything in the New Testament is written in actual fact after the establishment of the Church.
Why do I think this is directed at the Church? Because these are the crowds that are following Jesus and want to listen to what he has to say. Though it is true that to be a part of the Church, one then has to believe what he says, nonetheless this essential feature of the Church is present in this multitude: they want to hear Jesus.
Hence, being salt and light are functions of the Church. So what do they do? Salt nowadays is used to make things taste better, but back then the primary function was one of preservation. Salt preserved food from spoiling, and so we too are called to stop the world from spoiling. Is it not already spoiled by sin, though? Yes, to some degree. We are to keep it from spoiling further insofar as we are salt.
So the problem with being the salt of the earth comes when it does not make a difference, when having salt on or not is irrelevant - that is, it tastes the same either way. It has lost its taste. The Church stops being the salt of the earth whenever she decides that it is fine to be worldly, to assimilate into culture, to be just another institution, perhaps a bit older and wiser than the others, but relatively similar. She becomes not a force for preservation, but at most a reminder that at some point people thought it necessary to fight to preserve what was good. The Church, when it becomes an NGO, stops being the hands and feet of her Lord, and to put it how Jesus does, "it is no longer good for anything, but is thrown out and trampled under foot."
The Church must be different to everyone else, by the simple fact that her essence is not of this world. She holds the treasure of Christ in earthen vessels - but the outward appearance should never diminish the value of the endless riches stored within. To assimilate into worldliness means she has lost the treasure of Christ, for the world does not have Christ, only substitutes. 
Not only salt, but also the light of the world. On a slight tangent, those Bible scholars that are of the opinion that the gospel according to St John has another, non-historical Jesus, have this issue to contend with. In that gospel account, Jesus declares himself to be the light of the world whilst he is in it, and here, he endows that position to the Church, his body. There is a clear continuity even if certainly differences in style and sources.
Light has a very obvious function: it illuminates, allows us to see. The Church is the light by which the world can see. This is not a new task - Israel has been entrusted with this task already (cf. Isaiah 42:6). So we can infer that the Church must illuminate not any truth, but particularly the truths of God. Even more, the Church is to proclaim the radiance of the gospel of Jesus Christ, now a message entrusted with her until the age to come.
Given that she is light, what must the Church do? Show it. Jesus points out that when one has a light, it is never hidden - for why would one put a lamp under a basket? That is not what lights are for. They ought to be put atop a hill, or on a lampstand, so the whole house can receive illumination. The Church is now that city on the hill which must not and cannot be hidden - and again, this is not a new task. Anyone at the time would have known that Jerusalem was the city on the hill, Mt Zion. The Church is the New Jerusalem.
Being the light to the nations in the Old Testament, particularly Isaiah, meant speaking the word of God, and being the example for all others to follow. This has not now changed, and it is with our own lives that we must preach the word. Our light is Christ, and Christ is made manifest in our lives - always with the purpose of those works being seen to give glory to God, not to receive it ourselves. Entrusted as we are with a message, we cannot allow the Church to become just a do-good institution - yet we cannot in the same measure simply be tellers of Jesus' words and not also doers. Both are crucial to the Church.
 Interestingly, whether or not the Vatican recognizes a church organization depends on whether they have the Eucharist. So having Christ's very flesh is part of the Church in its very essence.