I think it’s interesting that in the Parable of the Ten Virgins Jesus said to the five foolish ones, “I never knew you”. In the Sheep and Goat judgment He says to the goats “depart from me” while in the Sermon on the Mount He says both: “I never knew you–depart from me”. Have you noticed that?
I believe in Matt. 25:12 Jesus said, “I don’t know you” or “I know you not.” In Matt. 25:41 it’s obvious by their behavior that the “goats” were never His.
By saying “I never knew you” in Matt. 7:23 He was dispelling the notion, popular in some parts of the Church, that the people he was speaking of are backslidden or rebellious Christians who have lost their salvation by not doing the Lord’s will. If that was the case He would have said, “I used to know you but not any more.”
By saying “I never knew you – depart from me” He was telling us the false prophets Matt. 7:15-23 refers to were never saved in the first place, even though they appeared to prophesy and perform miracles in His name. The lesson for us is that the manifestation of supernatural powers is not necessarily proof of salvation. The fruit they bear has to be consistent with the Word of God.