Jesus has warned that the gate to eternal life is narrow and few are those who find it. He says that's because there are false prophets who enter into churches looking to deceive you away from the narrow path. You will know them by the kind of lives they live, not by the talk they talk. Now Jesus fast-forwards us to Judgment Day where he paints a picture of these false prophets standing before him at the judgment seat. They plead to enter into the kingdom but instead they are met with these words of doom: "I never knew you. Depart from me, you who practice lawlessness."
I know this scene is usually applied more generally to the nominal Christian who professes Christ but has never really embraced genuine faith. The plea "Lord, Lord" indicates that they confess the name of Christ but never knew, loved or obeyed him. I think that's a valid application. This judgment scene is a fearful warning to all professing Christians. We need to examine ourselves and make sure we aren't just give lip-service to Christ but that we are bringing forth the fruit of righteousness.
This passage, however, does come on the heels of Jesus' warning about false prophets and seems to have them particularly in view. Jesus has already told us that they will come to us as sheep but are really ravenous wolves. They will claim to be prophets but are really deceivers. They will appear to be good trees but they will produce bad fruit. In this judgment scene Jesus continues his indictment against them. They will say, "Lord, Lord," but they do not do the will of the Father. They will appear to embrace Jesus' name but in fact Jesus never knew them. They seem to do great wonders for God but in fact they practice lawlessness.
Furthermore the works they lay claim to are none other than the signs of apostleship. These false prophets will appear to have the Holy Spirit's own endorsement of their leadership. Prophesying, casting out demons, and performing miracles are the deeds that accompanied the twelve apostles in the Book of Acts to mark them out as true delegates of Jesus Christ. Such powerful works of the Spirit are practically a letter of recommendation from Christ himself, a sign that says, "See, this man has the authority to speak in my name. Obey him as you would obey me."
You can't help but wonder how these false prophets came to possess such spiritual powers. Did these people know the power of the Holy Spirit at one time but then later abandoned the truth for worldly gain? Or were these powers from the devil all along? Is it even possible for Satan to duplicate such feats?
Jesus doesn't bother to comment on those questions. Instead he goes straight to the heart of the issue: if the man's life is lawless, even these signs of apostleship are worthless. That's how seriously we must take Jesus' warning about bad trees and bad fruit. If he is not doing the will of the Father, on the Day of Judgment Jesus will press the reject button. The guy could have paralytics leaping out of their wheelchairs from here to China, but if he's stealing money from the church or carrying on in adulterous affairs, he's false. Run, don't walk, in the opposite direction.