Blessed are those who are persecuted because of righteousness,
for theirs is the kingdom of heaven.
Blessed are you when people insult you, persecute
you and falsely say all kinds of evil against you because of me.
Rejoice and be glad, because great is your reward in heaven,
for in the same way they persecuted the prophets who were before you.
These beatitudes are probably the clearest of all that Jesus is not setting out a list of virtues that merit God's blessings, or as ethical requirements for acceptance into the Kingdom. As D.E. Garland has pointed out, being persecuted can hardly be an entrance requirement since this is neither something that one can do on their own, nor is it a virtue in and of itself (in Dictionary of Jesus and the Gospels, Blessings and Woes).
These final beatitudes summarise and climax the others. The persecuted are blessed if they are persecuted "because of righteousness" and "because of me [Jesus]". As we've seen, the concepts of righteousness and justice for the oppressed are closely linked in the Bible, and Jesus expects His followers to be righteous and to pursue justice.
Jesus never called for His disciples to withdraw from society, or to separate themselves from the communities in which they live. To the contrary, He calls for His followers to be a positive influence on the world around them - to be the "salt of the earth" and the "light of the world", to overcome evil by doing good, and to infect the world with a 'contagious holiness'. Too often religious groups set themselves apart from (and above) their neighbours and make distinctions based on creeds, dogmas and rituals. This is not the way of Jesus or the way of the Kingdom.
The beautitudes are the introduction to the Sermon on the Mount - Matthew's summary of Jesus' Gospel of the Kingdom. It's no coincidence that the final parable in the final sermon in this Gospel is about the basis of judgment and how people have treated the hungry and thirsty, the poor and naked, and prisoners. Jesus began His ministry by announcing that God will bring deliverance to the oppressed, and He ended it by declaring that this deliverance would come in part through the outward-looking practices of His followers who are focussed on relieving suffering, promoting justice and acting righteously.