"For I say to you that unless your righteousness surpasses that of the scribes and Pharisees, you will not enter the kingdom of heaven. (Matthew 5:20)
The Sermon on the Mount hinges on Matthew 5:20. If we do not consider it as we look at each part of the sermon, we will not understand the point of Jesus' message. The result is an overly moralistic message, different in content from the Pharisees but with the same legalistic attitude. In short, it won't be the gospel.
Matthew 5:20 is the hinge because everything Jesus says after explains in detail what it means for our righteousness to surpass that of the scribes and Pharisees. From Matthew 5:20 to the end of chapter seven, Jesus presents us with a picture of true righteousness, a righteousness not simply as an outward display but as an inward reality. And in Hebraic fashion, He teaches around the truth of true righteousness, circling with a permanent marker our need for a heart change.
Paul carefully explains in his epistles the underlying point of the Sermon on the Mount is our need to be justified, to be made right before God, and he spends more time explaining this heart change in terms of law than in terms of surgery. The Law is always in effect, both in the Old Testament and New Testament, and must be kept. Jesus fulfils the Law by keeping it perfectly, but the question on everyone's mind was, how can Jesus' obedience and righteousness be given to me? Otherwise, I have no hope of keeping the Law, and God would have to go against His justice to justify me.
In steps faith.
Faith is a confident trust in the work of Christ, both His obedience and His atonement, and a lack of works (to gain righteousness) shows it. Paul says, "…to the one who does not work, but believes in Him who justifies the ungodly, his faith is credited as righteousness…" (Romans 4:5). Faith transfers Christ's righteousness to our account, and God sees us as someone who perfectly kept the Law. Immediately, Paul is asked, "Do you nullify the Law through faith?" to which he responds, "May it never be! On the contrary, we establish the Law" (Romans 3:31).
Perhaps this is confusing to you. Faith without works, but a faith that works; Faith apart from the Law, but still upholding the Law. How can we make sense of this?
In steps Jesus Christ.
He perfectly kept the Law, fulfilling and upholding the Law. Faith in Him bypasses the Law because we do not attain our righteousness by the Law, but it still upholds the Law because it trusts in the One who kept it perfectly. Those in Christ still relate to the Law, but they do so through Jesus, for if they ever go back to attaining righteousness by the Law, Paul says they have "fallen from grace" (Galatians 5:4).
Without faith, we do not have Christ, and we are not recipients of grace. Without Christ and grace, we are not justified. They must all be present in perfect order for us to be saved, but that isn't the only reason faith is important for our salvation. Sin has so corrupted our nature that we must be saved unilaterally by God. In and of ourselves, we have no ability nor hope—that's what the Law tells us.
Righteousness must be given to us, justification must be declared over us, our hearts must be supernaturally changed, and the vehicle for all this is the faith given us by God through the gospel.
"For this reason it is by faith, in order that it may be in accordance with grace..." (Romans 4:16).