Jesus was severe with the Pharisees, calling them "whitewashed tombs" (Matt. 23:27), "hypocrites" (Mark 7:6), and sons of the devil (John 8:44). And yet, in Matt. 5:20, He points to them as He raises the bar for righteousness: "For I tell you, unless your righteousness exceeds that of the scribes and Pharisees, you will never enter the kingdom of heaven."
Jesus calls righteousness a requirement for getting into heaven. Some may want to downplay this statement out of a right concern for guarding salvation by grace alone through faith alone. But this statement is not about earning our way into heaven. Rather, it speaks to the function of righteousness and the law of God in the life of the Christian.
By perfectly obeying God's law, Christ merited righteousness for those who trust in Him. This we might call positional righteousness. Christ perfectly fulfilled the law in a way that the Pharisees, for all their scrupulousness, never could. And that flawless obedience counts for those who trust in Him, just as if they had perfectly kept the law themselves.
But Christ means something more. Throughout the Sermon on the Mount, He calls Christians to a deep understanding of and radical obedience to the law as reflective of the character of God (Matt. 5:48). Christians dare not treat His law lightly, because how we view God's law indicates how we view God Himself (Rom. 3:21). Thus, Christians are called to joyful obedience to His law out of love for Christ. This obedience bears practical righteousness.
This righteousness is not the basis of our salvation; we cannot merit justification by our works (Rom. 3:21–22). But it exceeds that of the Pharisees because their obedience did not come from the heart. And it is a mark that we have truly been saved and thus will enter the kingdom of heaven.
The righteousness that issues from this joyful obedience exceeds that of the Pharisees in kind rather than degree. Those of us who are in Christ have been saved from the law of God as the necessary means of salvation, but we have also been saved to the law of God as a way of loving and worshiping the God who has saved us (Rom. 6:19).