Since Jesus is our Lord we follow what he says. Even so, I agree with
@Barbara , that Jesus was drawing a contrast between behavior and attitude. We do well to understand why God gave certain laws and in the process learn more about the kind of God we serve.
Suppose, for instance that a father tells his son not to swing the baseball bat in the house. His son asks, "why father?" His father tells him, "swinging the baseball batt in the house might damage property or hurt people."
One day a fire breaks out in the house and the only means of escape is to break a window with the baseball bat. When the father and son meet outside, safe from the fire, the father says "son, I am proud of what you did today." His son asks, "why father? I disobeyed your command against swinging the baseball bat in the house." The father says, "Yes, that is true. But you also learned to value life more than property and didn't hesitate to make that decision."
When we read and study the Sermon on the Mount, we are coming to understand the father better, what he values, and what he loves. And he expects us to learn wisdom and act in ways that emulate his values.