As I read this there seems to be a discrepancy? Have you noticed it?
"...did we not prophecy in Your Name"
"and in Your Name cast out demons,"
"and in Your Name cast out demons,"
"and in Your Name perform many miracles?"
"...depart from Me, you who practice lawlessness."
The last time I checked, those weren't acts of lawlessness. And they did it in Jesus' name: prophesied, cast out demons, performed miracles. So what's the catch?
The fact is that God uses whatever He will to accomplish His purpose. He uses pagan kings: Pharaoh, Nebuchadnezzar, Cyrus. He uses calamity, natural disasters, even our sin according to His wisdom and for His desired purpose (Ephesians 1:11).
That means God doesn't get a kick-back from my deeds on His behalf. They don't make Him bigger, better, more holy, more anything. He already is. The fact is, what I do has less to do with Him and more to do with me. It is a blessing and privilege to be His instrument, used in cooperation with His Hand, Spirit, and Word. I am the one who benefits from obedience.
But if I am not personally, submissively, volitionally connected to Him, there is no benefit whatsoever. Jesus said:
"I am the vine, you are the branches; he who abides in Me and I in him, he bears much fruit, for apart from Me you can do nothing." (John 15:5)
Does that mean we can't do "good" things? It depends on how you define, "good." If you define it as something that benefits others or society at large, sure you can do good things. Anyone can. The individuals mentioned earlier prophesied, cast out demons, and did miracles. Those are good things.
Fruit is a natural outcome of being. Apple trees produce apple because that is what they are. It is their genetic make-up. It is part of their being. The tree is a living organism that works to draw nourishment, energy, and identity from its root and trunk. The fruit it produces is a function of the tree itself.
You and I can do all kinds of things on our own that other people see as good. We can be self-disciplined, moral, helpful, productive, and generous. But we can do all these things from a root of pleasing ourselves and others. The source of living and giving is no deeper than our own effort, self-reliance, and self-motivation. When that is the case, the fruit may look the same in some respects, but it is not godliness. It is self-righteousness. The work is done to promote myself; it is short-lived and my expectation determines its success. If it doesn't meet my expectations, I am crushed. If people don't notice, care, or appreciate my efforts, I feel like a failure. Why? Because the root of all the "good" things I do is shallow: it's dependent on and driven by me.
But to be connected to Christ is to be free from performing, doing, and its earthly ramifications. When my Source is Jesus Christ, He provides the nourishment, energy, desire, identity and opportunity. My efforts and expression of life is not dependent on me, nor am I dependent on them. My sole dependence is on my Savior and His love for me. In every moment? No, not yet. With never a disappointment? Not yet. But more and more as I grow in understanding, knowing, and practicing what it means to abide in Him and His words abide in me. So the fruit I bear, the life I live, the choices I make are a natural outcome of being.
What I do does not define who I am; who I am defines what I do.
And when I am hidden in Christ, He is glorified as the Doer, the Producer, the Giver. I am simply a conduit--and blessed to be one.
“I am the true vine, and My Father is the vinedresser. Every branch in Me that does not bear fruit, He takes away; and every branch that bears fruit, He prunes it so that it may bear more fruit. You are already clean because of the word which I have spoken to you. Abide in Me, and I in you. As the branch cannot bear fruit of itself unless it abides in the vine, so neither can you unless you abide in Me. I am the vine, you are the branches; he who abides in Me and I in him, he bears much fruit, for apart from Me you can do nothing. If anyone does not abide in Me, he is thrown away as a branch and dries up; and they gather them, and cast them into the fire and they are burned. If you abide in Me, and My words abide in you, ask whatever you wish, and it will be done for you. My Father is glorified by this, that you bear much fruit, and so prove to be My disciples. Just as the Father has loved Me, I have also loved you; abide in My love. If you keep My commandments, you will abide in My love; just as I have kept My Father’s commandments and abide in His love. These things I have spoken to you so that My joy may be in you, and that your joy may be made full.
“This is My commandment, that you love one another, just as I have loved you. Greater love has no one than this, that one lay down his life for his friends. You are My friends if you do what I command you. No longer do I call you slaves, for the slave does not know what his master is doing; but I have called you friends, for all things that I have heard from My Father I have made known to you. You did not choose Me but I chose you, and appointed you that you would go and bear fruit, and that your fruit would remain, so that whatever you ask of the Father in My name He may give to you. This I command you, that you love one another." (John 15:1-17)