No New Covenant believer is under the Law, obliged to fulfill it perfectly in order to connect with God (Galatians 3:1-3; Romans 3:20-24).
We are obliged to strive to obey the 10 Commandments and the Spirit of God enables us to do so. Any stumbling in our efforts is covered by James 3:2, but nobody stumbles who is not already attempting to walk upright.
He did NOT say obedience to God's commands was the means of obtaining the Holy Spirit.
Anybody can read those verses for themselves and see clearly what they say.
He that has been made aware of My Commandments,
and keeps them, ... I will manifest Myself unto him. ... If a man loves Me,
he will keep My (Commandments) ... and We will come to live with him."
John 14:21 & 23
There's no way to deconstruct that passage, with honesty and integrity, and not come away with a clear
condition of keeping the Commandments.
The indwelling Holy Spirit is obtained solely by faith in Christ as one's Savior and Lord. (Romans 10:9-10; Revelations 3:20; John 3:16)
Faith is a gift.
1 Cor. 12:9
Eph. 2:8
Phil. 1:29
Jude 1:3
What we do with that gift is entirely up to us. That is what the parables of the invested, or un-invested, money is about. God gives a measure of faith. We are to do certain things to grow, and spread, that faith.
One of the specific things we are to do with that faith is to seek Christ in God's Word and learn and obey. Obedience is done in, and by, faith - just as our works are done by means of faith. Faith without works is a dead faith.
Obedience to the 10 Commandments is a work of faith. No, it is not works salvation as it is the Spirit of Christ that motivates and enables us to do so. Phil. 2:13
Matt. 7:21-23 demonstrates the outcome for those who live a life of professed Christianity but without obedience to God's Law. Jesus tells these poor souls that they are rejected for being
workers of iniquity (sin - breaking the Commandments). He also tells them He never knew them. And why did He never know them? Because their lack of obedience to the Commandments never allowed His Spirit to come and live with them.
Christ is the foundation of righteousness for the New Covenant believer.
And what did Christ do in His lifetime to demonstrate righteousness?
He obeyed all of the 10 Commandments. John 15:10
He also taught them all so that there could be no mistake. Matt. 23:1-3
Holiness is the by-product of fellowship with God, not the goal of fellowship with Him. God is Himself the point of the Christian life. To make morality the chief aim of the faith is to embrace moralism which, as the Pharisees well-demonstrated, inevitably leads away from God into hypocrisy.
Holiness is the means by which we fellowship with God. We are told to be holy and perfect as God is perfect. Matt. 5:48
The True Christian is to be always striving for holiness and perfection, ever removing sin and unholiness from their lives; constantly separating oneself further and further from the ways of the fallen and unholy world. It is a constant battle that we are to endure right up to the moment of our death.
As far as the Pharisees go, none of them ever obeyed the Commandments. They taught them yet never obeyed them. They were the epitome of hypocrites as Jesus made scathingly clear in Matt. 23. He told His disciples (the first Christians) to do as they taught, but not as they did. Matt. 23:3
What they taught were
the 10 Commandments.