It seems that a good bit of the Sermon on the Mount flows from Jesus’ statement: “Unless your righteousness exceeds that of the scribes and Pharisees, you will never enter the kingdom of heaven” (Matt. 5:20).
The remainder of chapter 5 provides Jesus’ hearers with six examples that demonstrate the common understanding of the Law did not rise to Jesus’ expectations of righteousness. (In some cases this was due to a mishandling of the law [e.g., Matt. 5:33-37, 43-47]; in other cases this is due appreciating only the external aspects of the law [e.g., Matt. 5:2-26, 27-30]—something Israel’s prophets condemned; in other cases this is due to a failure to see that the law pointed beyond itself to a higher ethic [e.g., Matt. 5:38-42; 31-32; with Matt. 19:8-9]).
The expected standard is stated in Matthew 5:48: “You therefore must be perfect, as your heavenly Father is perfect.”
Chapter 6 continues the focus on righteousness. It begins with the governing statement: "Beware of practicing your righteousness before other people in order to be seen by them, for then you will have no reward from your Father who is in heaven.” [Note the interesting connections between this verse and Matt. 5:12, 16.]
What follows (Matt. 6:2-4, 5-15, 16-18) are three examples: Don’t give alms to be noticed; don’t pray to be noticed; don’t fast to be noticed.