Notice the following scripture wherein Jesus states He does not know those who profess to know Him. These people were prophesying, casting out devils and doing many wonderful works in His name. How is it possible that Jesus would say, “I never knew you?”
“Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven. Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works? And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.” Matthew 7:21-23
One should consider what was missing.
The following scripture shines light on the concept of something missing as well:
“But when they believed Philip preaching the things concerning the kingdom of God, and the name of Jesus Christ, they were baptized, both men and women. Then Simon himself believed also: and when he was baptized, he continued with Philip, and wondered, beholding the miracles and signs which were done.” Acts 8:12-13
The preceding scripture indicates Simon believed he needed to be water baptized and indeed was water baptized in the name of Jesus.
Notice afterward that Simon didn’t believe and act upon the entire gospel message of repentance, water baptism AND the Holy Ghost baptism, in the correct way, so Peter said he would perish:
“When Simon saw that through laying on of the apostles' hands the Holy Ghost was given, he offered them money, Saying, Give me also this power, that on whomsoever I lay hands, he may receive the Holy Ghost. But Peter said unto him, Thy money perish with thee” Acts 8:18-20
The bible records that everyone must believe the gospel message of Jesus’ death, burial, and resurrection. Afterward scripture shows how those believing the entire message regarding Jesus as their messiah are to put their faith into action by following the steps outlined on the Day of Pentecost; repentance, water baptism and Spirit baptism. (Acts 2:38)
Obedience to all of the elements is necessary and is clearly seen throughout scripture. Knowing this fact one can see a possible answer to how Jesus could say “I never knew you.” Something was missing.
If one realizes that the bible records that some people receive the Holy Ghost baptism first, and are water baptized afterward, (Acts 2:38, 10:44-48) and others get water baptized first and receive the baptism of the Holy Ghost afterward (Acts 8:12, 19:1-6) a plausible answer appears.
An individual who receives the infilling/baptism of the Holy Ghost, with the evidence of speaking in tongues, has the Spirit of God within their mortal body. The indwelling Spirit flowing through an individual makes prophesy possible, casting out devils/demons, and enables many wonderful works to be done such as; healing, etc. However, receiving the Holy Ghost, in and of itself, is one component needed to gain entrance into eternity.
The gospel message in its entirety must be obeyed in order to gain entrance into the eternal Kingdom of God. Remember Jesus specifically stated: “Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father…”