Jesus said in John 8:31, If you continue in my word, then are ye, my disciples. To continue in His word means to obey what He says. Obedience to God is learned behavior. As you learn of God by way of Holy Spirit, you do what you have learned just like anything else. The difficulty to keep God's commandments comes when there is an attempt to enforce more than one behavior. Behavior is how you act or respond based on information obtained. In other words, whatever you learn, you do.
Your obedience to God must be learned behavior because there was already a previously set behavior. Before having a relationship with God, we all obeyed the devil by default; it is what we learned to do. After learning of God and making the decision to live holy, action needs to be taken. Jesus said in Matthew 11:29, Take my yoke upon you, and learn of me... It is impossible to learn what you don't know without information. When you take the yoke of Christ, you join with Him. You join His cause and way of life. There becomes a purposeful goal to find out what would Jesus do and respond like-kind to what you learn. You do exactly what you learn about Jesus, therefore becoming obedient to God through learned behavior. In order to do this, there is the need for Holy Spirit. Only Holy Spirit can tell you how to behave in obedience to God. But the Comforter, which is the Holy Ghost, whom the Father will send in my name, he shall teach you all things, and bring all things to your remembrance whatsoever I have said unto you. John 14:26
We all are obeying what we have learned at all times but in order to obey God, you must deny all you have learned elsewhere. When this is done, the acceptance of what God is teaching becomes easy to do. There is the removal of two opinions. Holy Spirit keeps us learning behavior which promotes obedience to God.
In the teaching of Jesus, we are told to deny man, including self, in order to be His disciple. When this action is taken, we are learning to behave according to God's will. We are obedient to only God, thereby fulfilling the commitment of righteousness to Him alone. You now have obedience through learned behavior.