Those who say that Paul's words mean that one does not have to obey God in order to receive His Spirit simply do not understand what he was talking about. They also do not understand the circumstances that the apostle was addressing. The main problem in the churches in Galatia was that people were being taught that they could be justified—have their sins forgiven and be brought into a right relationship with God—by lawkeeping. The people's minds were being turned away from faith in Jesus Christ. Paul was reminding them that the only way anyone can receive forgiveness of sins is through faith in Christ's sacrifice.
To drive his point home, Paul reminds the Galatians that they did not receive God's Holy Spirit by lawkeeping while ignoring faith in the sacrifice of Christ. He points out that, without faith in the sacrifice of Christ, no one can be justified, no one can be forgiven of sins, and no one can be given the gift of God's Holy Spirit.
This does not negate the fact that there are still basically two requirements for receiving God's Spirit, namely, repentance and faith in Christ. Both of these requirements must be met before one can receive the Spirit. Repentance involves turning from sin and turning toward obedience to God's commandments.
Earl L. Henn (1934-1997)
Is Obedience Required Before Receiving God's Holy Spirit?