I think it’s important to notice that Jesus includes the Torah and the Prophets in his claim to uphold scripture. The Law needs to be read in light of the prophets, and vice versa.
Jesus says the Law is upheld, not abolished. He came to fulfill it.
I believe it is legitimate to take this little section as an introduction to the six points of law Jesus will talk about next in his Sermon. Far from loosening the law, he will tighten it. He will fill it out with his teaching and with his life. And he expects the same from his disciples.
Craig Keener says it well:
Jesus essentially says, “Look, if you thought the law was tough, wait till you see this. If you really want to be my disciples, give me your hearts without reservation”
Craig S. Keener, Matthew, vol. 1, The IVP New Testament Commentary Series (Downers Grove, IL: InterVarsity Press, 1997), Mt 5:17.
The prophets harshly judged those who kept the Law on the surface, but whose hearts were not in it. It looks like Jesus stands in that tradition. The Law and the Prophets.
Let us give Jesus our hearts without reservation.