I think you are missing a key understanding in this passage and in the word. The problem with those mentioned is that Jesus never knew them. There will be many who, like these, will suppose that they are accepted by what they do, so they will focus on these...Lord, Lord did we not DO all these things in your name? But what does Jesus say..."I never knew you" He will not say I used to know you. He will say "never". Therefore these were never in the family of Christ. They were never regenerated in the first place. Therefore they will be judged according to the law. And we know that if anyone fails on any one point of the law, he will be guilty of all the law. Those who are lost will be judged as workers of iniquity. Those who are His by faith have escaped judgment, as Jesus promised in John 5:24..." Most assuredly, I say to you, he who hears My word and believes on Him who sent Me HAS EVERLASTING LIFE, and shall not come into judgment, but has passed from death into life".Mat 7:22 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?
Mat 7:23 And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.
The many could also say 'Have we not believed?'
The key is that they are workers of iniquity, unrighteous, and are rejected for this.
G458
a̓νομίa
anomia
an-om-ee'-ah
From G459; illegality, that is, violation of law or (generally) wickedness: - iniquity, X transgress (-ion of) the law, unrighteousness.
Many claim immunity for their violation of God's law, but Christ himself tells us he will reject those.
So this question of yours " The many could also say 'Have we not believed?" , is an assumption that is not based on scripture. The conclusion in Heb.10:39 states that " we are not of those who draw back to perdition but of those who believe to the saving of the soul"
The promise in 1John2:1 is that "if we do sin, we have an advocated with the Father"
The purpose for quoting these is not to promote sin or to excuse it, but to assure those that the promise of God is yes and amen, which is that in the new covenant..." their sins and lawless deeds I will remember no more".
We are saved because God is good, not because we are good. He solved the problem. It is not for us to help Him solve it. We cannot save ourselves. John17:3..." and this is eternal life; that they may know You, the one true God, and Jesus Christ who you have sent" In Rev.3 Jesus' solution to the lukewarm church is found in vs.20,21. ".. I stand at the door and knock. If anyone hears My voice and opens the door, I will come into him as sup with him and he with Me". Thus He will never say to these.." I never knew you"