Matthew 7: YLT
21 `Not every one who is saying to me Lord, lord, shall come into the reign of the heavens; but he who is doing the will of my Father who is in the heavens.
22 Many will say to me in that day, Lord, lord, have we not in thy name prophesied? and in thy name cast out demons? and in thy name done many mighty things?
23 and then I will acknowledge to them, that -- I never knew you, depart from me ye who are working lawlessness.
Looks like those saying "Lord, Lord" are claiming their deeds would gain them entry.
Jesus said only those doing the will of the Father would enter. What is the will of the Father?
Did you just ignore the word "lawlessness"? Lawless, or iniquity is sin. You ignoring this. 1 John 3:4 says, "sin is the transgression of the law." Jesus says to depart from Him not because they are doing wonderful works alone. That is backwards in your thinking.
Jesus says to depart from Him because they worked "iniquity" or "lawlessness" (along with their doing wonderful works). When you say to others that they can sin and still be saved (Because they have a belief on Jesus), you are telling them that they can work iniquity or lawlessness. But this is the very reason Jesus said to depart from Him. This is proven by the fact that Jesus says in verses 26-27 that he that does not do what Jesus says is like a fool who built his house upon the sand, and when a storm came, great was the fall of it. Jesus's final point here was not OSAS. It was verses 26-27 that says that you must do what He says. In addition, Jesus says not everyone who says unto Him Lord, Lord will enter the Kingdom of Heaven, but He that does the will of the Father. What is the will of the Father or God?
Let's look at Scripture.
"God's will is for you to be holy," (1 Thessalonians 4:3) (NLT).
Hebrews 12:14 says that without holiness, no man shall see the Lord.
Titus 1:16 says you can deny God by a lack of works.
Hebrews 5:9 says that Jesus is the author of eternal salvation to all who OBEY Him.
You said:
And this is the will of him that sent me, that every one which seeth the Son, and believeth on him, may have everlasting life: and I will raise him up at the last day.(John 6:40)
But what does "believe" or "faith" look like according to Scripture?
We know that when Peter failed to walk on water, Jesus said, you have little faith.
Can you imagine what would have happened if Noah did not believe God in building a boat?
He and his family would have perished along with everyone else.
Also believing in Jesus includes believing not only in the person of Jesus, but believing everything that He taught and commanded of us. One is not believing Jesus if they are disobeying Him.
James says faith without works is dead. Faith and belief are the same thing. So one's faith or belief is dead if they do not have works. For even the demons believe and tremble. For Jesus says, why do you call me Lord, Lord if you do not do what I say? Think. What King would allow one of his servants to be disloyal to Him? A person has a master or Lord because they are servant to that Lord or master. If one is serving themselves or sin, they serving two masters. Yet, Jesus says, you cannot serve two masters.
Hebrews 11 shows us that faith or belief always leads to right actions and not sinful actions.
Belief is more than just having a mental acknowledgment that Jesus is your Savior alone.
Let me give you an example:
If God told Bob to sit in a porch chair that he knew could not hold his weight, and God said to trust Him that the chair will not break and Bob refused to sit in the chair (and yet Bob said he trusted God). Can you say that Bob was truly trusting or believing in God? No. It is the same when we see God's Commands within His Word and we refuse to do them. We are not trusting or believing God if we refuse to do what He says.