There are a few things going on here. Jesus affirms that the law is still in effect. He has not removed the law. He has come to fulfill it. When you read the remainder of the Sermon on the Mount, Jesus makes it clear that the moral requirements of the Mosaic law are still firmly in effect. When we read Paul and James and others, who constantly refer back to the law, they constantly quote it either to testify to a New Testament reality, or to instruct the believers on a certain point of behavior. Paul even uses the Mosaic law that states Israelites are not to muzzle the ox while it is treading, for example, to demonstrate that congregations should see to the physical needs and support their pastors. James, in Acts 15, mentions that the law is taught even to the Gentiles. That being said, Jesus has fulfilled the law. He came as the high priest and the lamb to offer himself as a sacrifice that we might be made righteous. In doing away with the penalty of sin in his own body, he did away with the distinction between Jew and Gentile, and in so doing, those requirements of the ceremonial law drawing distinctions between the two peoples and for making atonement through sacrifice were fulfilled and no longer binding.
That being said, Paul upholds the law in Romans and elsewhere. He seems to allow for three uses of the law: 1) as a curb, 2) as a mirror; and 3) as a guide. In Romans 1, 2, and 13, Paul indicates that the law is used to communicate what bad behavior is and empowers the government to punish evildoers in order to maintain order on earth. In Romans 3 and 7, Paul indicates that the law shows us our sin and drives us to Christ as our savior, through whom we are made righteous by faith. And in Romans 12, Paul uses the law as a guide to show Christians how they ought to function as the sanctified body that we might do the works God has set out for us to do and to demonstrate our love for one another.