1) To reaffirm that the intent of the Old Testament law was to espouse principles of character not of legal minutae (in direct contradiction of the common teaching of the Pharisees);
2) therefore, to set before people an impossible moral standard to live up to (not some petty list of rules that it might theoretically be possible to keep, if you were a Pharisee at least);
3) thus, also fulfilling the OT law’s purpose of showing mankind our need for a Saviour to restore us to right relationship with God, because we aren’t capable of reconciling ourselves to the Creator from whom we are estranged by sin and all its consequences;
4) while also placing before us an assurance that God’s desire is to bless people, to have them in His fellowship;
5) and showing us the principles of character that we should seek to ‘put on’ as Christians, for reasons fo living out the right relationship with God we already have, not for reasons of winning favour with God.
This is why it starts with a statement of the blessings of the poor in spirit, the humble, etc and ends with a statement of the sure position of those who build their lives on Christ’s teaching. IE it’s a sermon about the grace of God and the free gift of righteousness that comes through faith.