Matthew 5:1-7:29 is the famous Sermon on the Mount. It is the first major discourse of Jesus in the Gospel of Matthew and is the first time that Jesus is formally presented as the New Moses. In Matthew 2:13-23, Matthew had presented Jesus as the New Moses through well-placed fulfillment passages within a story about Jesus escaping a king's paranoidal attempt to prevent anyone grabbing his throne. Here, Jesus actually lays down the constitutions of the kingdom that he proclaims. Within this instruction, 5:3-12 make up a preamble to the constitutions.
5:1-2 presents the setting of the discourse, a mountain with the crowds and the disciples as audience; 7: 28-29 closes the discourse with a remark about the reaction of those who heard Jesus. 5:3-12 stands out from the discourse because of its particular form. It is composed of macharisms, statements that begin with the word "Blessed". These are sayings that one can find strewn around in prophetic, psalmic and wisdom literature of the Old Testament. These macharisms have the pattern "Blessed" + those who are called such + the reason why they are blessed. The pattern is discernible in vv. 3-10. In vv. 11-12 the pattern breaks: verse 11 introduces first and second person pronouns and v. 12 uses "Rejoice and be glad" instead of "Blessed" with the addition for the reason for rejoicing. In addition, v. 3 and v. 10 form an inclusion with "kingdom of heaven". This inclusion makes "poor in spirit/persecuted for the sake of righteousness" and all the nouns in between refer to the same group of people, those called YOU (v.11, second person plural)1. The "reward" (v. 12) for them are those designated by "kingdom of heaven" and those statements that follow "for they..." in vv. 3-10. In other words, the beatitudes constitute the way Jesus sees the disciples who have come towards him, with the crowds "listening in".

The original set of macharisms are found in Luke 6:20-23
Blessed are you poor, for yours is the kingdom of God.
Blessed are you that hunger now, for you shall be satisfied.
Blessed are you that weep now, for you shall laugh.
Blessed are you when men hate you,
and when they exclude you
and revile you,
and cast out your name as evil,
on account of the Son of man!
Rejoice in that day, and leap for joy,
for behold, your reward is great in heaven;
for so their fathers did to the prophets.
Those who are "poor", "hungry", "weeping" and hated and excluded are descriptions of a group of people who are experiencing difficulties from an environment that has outcasted them. They are designated "blessed" because in the final analysis (when the time of vindication arrives) they are the winners. To this primitive macharism, Matthew has added some new ones while rewriting some (e.g. "poor" becomes "poor in spirit"; "those who hunger" become "those who hunger and thirst for righteousness"). The audience in Matthew was different from the ones addressed by Luke and the "spiritualization" of the Syrian-church-based gospel is an attempt to give the beatitudes wider coverage so as to fit a more variegated community. Thus, while "poor in spirit" is a spiritualization of Luke's "poor", it does not exclude those who are materially poor, but rather puts poverty within a context that is already familiar among those who pray the psalms, namely, the poor as those whose who have learned to put their trust in God alone and not in any other security (the anawim). "Poor in spirit" in this sense would also include those who were rich before but because of being persecuted for the sake of Jesus, were deprived of their wealth.
The situation of persecution which the Churches experienced from the beginning of their existence explains the groups of people designated by the word "Blessed". Mourning characterizes those who -- being exluded from the acceptable society -- are separated from family members and friends. The meek are those who have learned to control their anger and instinct to render "an eye for an eye" in moments of persecution or insult such as the one referred to in 5:11 (cf. 5:38-41). Those who hunger and thirst for righteousness are those who experience the unfairness of being persecuted simply because of their faith and therefore wish that the "right thing"2 (e.g. respectful tolerance) be shown to them. The merciful are those who have learned to pardon and forgive those who wrong them (the persecutors) and who give consolation the brothers and sisters who suffer the same fate as they do. The pure of heart are those who are sincere in their commitment, not pretending or showing-off. The peacemakers are not only those who try to live peacefully with others but whose lives makes reconciliation possible. The members of Matthew's "ecclesia pressa" are "blessed" precisely because their righteousness -- their life-style -- is higher in quality and closer to what God desires than that of the show-offs, the Pharisees (cf. 5:20).
It is to be noted that in four of the macharisms, the reason for blessedness corresponds to the characteristic of the group, thus those who mourn are consoled, those who hunger and thirst are satisfied, the merciful receive mercy in their turn. There are three cases where the corresponding reason for blessedness is not immediately obvious: "meekness and inheriting the earth", purity in heart and "seeing God", peacemakers as "sons of God.". It has been suggested that the macharism on meekness is based on Psalm 37:11
the meek shall possess the land,
and delight themselves in abundant prosperity.
Psalm 37 is an acrostic psalm that is didactic in character. It contains exhortations to fidelity, patience and trust in God inspite of the "unfairness" of seeing the wicked apparently prosper. The meeks' possession of the land is in obvious contrast to the wicked (Ps. 37:10) who will not last wherever they are. At a time when the mighty and powerful can extend their boundaries with impunity, Ps. 37:11 is an admonition not to imitate what the unjust are doing. Since the wages of sin is death, and violence is the comeuppance of the violent, the meek and the patient will be vindicated since "the Lord loves justice; he will not forsake his saints. The righteous shall be preserved for ever, but the children of the wicked shall be cut off" (Ps. 37:28).
God is normally "heard" not "seen". But for the those with a "pure heart" the reward is vision of God. Ps. 24:3-4 mentions "pure heart" as a requirement for standing in God's presence.
Who shall ascend the hill of the Lord?
And who shall stand in his holy place?He who has clean hands and a pure heart,
who does not lift up his soul to what is false,
and does not swear deceitfully.
It is the heart that "seeks the face of God" (cf. Ps. 27:8). The macharism in Matthew 5:8 highlights the correspondence of the vision to the heart that in purity seeks God's presence.
Finally, the correspondence between "peacemakers" and "sons of God" becomes clearer when understood within the context of the Israelite greeting "Shalom". "Peace" is not just the absence of war, but a situation where there is nothing lacking. Augustine defines it as the "tranquility of order". It is a definition that is based on the Stoic concept of "oikeiosis", "at-homeness". Peace is being at-home with oneself, with others, with the world and with God. The Israelite greeting "Shalom" is a wish that this at-homeness, which derives from the God of the covenant, may be shared by both the one who greets and the one greeted. On the level of day-to-day living, it has the force of promise based on the covenant that he who greets would live in such a way that the other may truly experience this peace3. They are therefore "sons of God" because sons of the Covenant that is divinely guaranteed as bringing about peace.
1The rest of the discourse will deal with this "You", second person plural.
2One can also interpret "righteousness" here as submission to God's saving will (cf. Oxford Annotated NRSV, note in loco). In other words "the right thing" would be to live under the reign of God inspite of the opposition to it.
3One can for example cite Jeremiah 9:8 for an opposite case:"Their tongue is a piercing arrow, it hath spoken deceit: with his mouth one speaketh peace with his friend, and secretly he lieth in wait for him."