This reminds me of students who don’t want to do the coursework, but they try to offset their dereliction by doing extra credit or kissing up to the teacher at the end of the year. They are looking for a way to get around the things they would rather not do. In Christ’s teaching here, the basic responsibility—the coursework—is obedience to God’s will, which is outlined in His word. God does not require prophesying, casting out demons, or doing wonders. Now, if you have been gifted with those things, then you should use those gifts. But those gifts won’t offset practicing lawlessness. God’s law is non-negotiable. The end of these many is that the One who could save them declares, “I never knew you; depart from Me.”
And we know from I John 3:4 that sin is the transgression of God's law. So these are lawbreakers. Now, the people Jesus was referring to here, they actually thought they were worshipping God, and that they were acceptable to Him.