In the Sermon on the Mount, Jesus is correcting misinterpretations of the Law of Moses that He and others have been hearing in the synagogues for the past 30 years. In the gospel narratives, Jesus is described as traveling throughout Israel teaching in the synagogues (Matt. 4:23). "Large crowds" are now following Him (v. 25), and He has called His twelve disciples (5:1-2). After describing what a citizen of the kingdom is in The Beatitudes (5:3-12), and how citizens will be viewed by worldly people (vs.11-12), and how we are to view ourselves (vs. 13—16), Jesus immediately confronts the idea that He has "come to abolish the Law or the Prophets," stating that He has not come to abolish them, but to "fulfill" them (5:17-20).
I understand Matthew's usage of Jesus' words to mean that He is making plain what was a "mystery" in the OT (the classical argument of the OT conceals what the NT reveals) by contrasting what God actually meant with what the Pharisees and scribes had (mis)interpreted it to mean. Jesus and His apostles are "enemies of the state" being falsely accused of subverting God's nation (Mark 14:55-59; Acts 21:28). Immediately following Matt. 5:17-20, which concludes with the thought that "except your righteousness" (integrity, not moral superiority) "exceeds" (is more evident that you are real and not fake) that of the scribes and Pharisees, ye shall not enter into the (coming) kingdom" that He and John the Baptist have been announcing for about a year now--Jesus now begins correcting these misinterpretations of the Law which came as a result of these teachers being covetous hypocrites (Matt. 23:1ff).