The Sermon on the Mount constantly uses the Old Testament, either by allusion or quotation, so the use of a psalm in Matthew 7:23 is no surprise: “And then I will declare to them, ‘I never knew you; depart from me, you workers of lawlessness.'”
The scene is judgment day (Matt 7:22), and Jesus is refusing kingdom entrance to those who had a mere confession (7:21) without a heart-life commitment to him. In reply to their protest (7:22), he dons the words of David. The genealogy and birth account in Matthew 1 show that Jesus is the true and greater David who will lead his people from exile and rule in righteousness. In Matthew 2, the wise men seek him in Bethlehem, the very town where David had been born (2:2-6). We might expect that Jesus would give David’s words (particularly in the Psalms) their greatest, fullest significance and application.
As Jesus nears the end of the Sermon on the Mount, he quotes a Davidic psalm and evokes its context. In Psalm 6:8, David wrote, “Depart from me, all you workers of evil.” Psalm 6 was a prayer that God would be gracious to David, and near the end it shows confidence that God’s enemies will be ashamed. The prayer is for vindication. “How long” until deliverance? (6:3-4)? Then the good news is welcomed: David’s prayer is heard (6:9)! David is vindicated! His enemies must flee!
Jesus, the long-awaited Davidic king who will reign forever, has an eschatological role in Matthew 7:23. He is exiling unbelievers from the kingdom’s gate, saying, “Depart from me.” He calls them “workers of lawlessness,” using the same phrase as the LXX of Psalm 6:9 (6:8 Eng.). God’s enemies on judgment day will face the shame of eternal exile and divine rejection. To reject the Son is to align yourself against his Father.
Jesus is the Davidic King, and on the day of final judgment he will not be speechless. He will speak with sovereign and final authority, and any who contend shall do so in vain.