The Bible verse you are referring to regarding what it means to grieve the Spirit is in Ephesians 4. It states, "Do not let any corrupt communication come out of your mouth . . . and grieve (Greek: lupeo, Strong's Concordance #G3076) not the Holy Spirit of God by which you have been sealed for the day of redemption" (Ephesians 4:29 - 30, HBFV throughout).
The Greek lupeo means to "cause pain, distress, to be sad or to grieve." The Bauer-Arndt-Gingrich Greek-English lexicon states the word means, in relation to the Holy Spirit, to "vex, irritate, offend, insult" and agrees it is a synonym for grieve.
It should be noted here that the Bible does not support the teaching that the Holy Spirit is a person or a part of some Triune Godhead. It is, rather, the power through which God (the Father and Jesus Christ) accomplish their will in the universe. How can we then insult, grieve or offend it? If we look at the context of Ephesians 4:30 we will find our answer.
Ephesian 4:17 - 22 reminds Christians that they should not follow the foolishness, vanity and lusts of their human nature as they did before they were converted. Believers are to be renewed in their minds (verse 23) through God's power (2Timothy 1:6). Those called by the Eternal are to become a new person (Ephesians 4:24) through the indwelling of Jesus (Colossians 3:10 - 11) and not lie.
We are also not to let our anger get out of control, thereby giving the devil a chance to tempt us (Ephesians 4:25 - 27). We are to not steal but rather work as God intended so that we can not only provide for ourselves but also have something to give to others (verse 28).
We are not to use filthy language as the unconverted do but rather work toward building up others (verse 29). We grieve it, the Spirit, by engaging in the immoral actions Paul lists.
How serious is it?
How serious is it to grieve the Holy Spirit that makes him or her a true Christian? Consider what Christ taught in Matthew 12.
And whoever speaks a word against the Son of man, it shall be forgiven him; but whoever speaks against the Holy Spirit, it shall not be forgiven him, neither in this age nor in the coming age (Matthew 12:32).
Why does God regard insults against the Holy Spirit as worse than insults against Jesus? It is possibly because it is the means by which Christians are guaranteed eternal life if they remain faithful to the end of their human existence. Its continued presence in our lives is necessary for salvation (2Corinthians 5:5). Paul tells us in Colossians 1:27 that the mind of Christ in us is the hope of glory or final salvation.
Whenever we sin, we grieve the Holy Spirit. God wants us to resist and avoid sin as much as possible. He will not withdraw or lessen his presence in us as long as we recognize our mistakes and weaknesses and repent. Our loving Father knows we are still human and subject to the flesh. He promises to forgive us if we ask him and to cleanse us of all unrighteousness (1John 1:7 - 9).