Verses 6 and 7 is a concluding statement. It begins with,
The gist of it is that because God forgives sin, those who are in a covenant relationship with Him can have true happiness. They can have true blessedness. We can trust; we can have faith that God will forgive us when we fail Him because that is His nature, that is the covenant that we have signed on to. One of the parts of the covenant that He says He will do is forgive our sins. That is part of His role.
And so when we come before Him and ask Him for forgiveness in the right attitude and the right spirit, He is going to do it. So all those who are godly, meaning those who are in the covenant, shall pray to You in a time when You may be found, meaning in their day of salvation, in their opportunity for salvation. And You will hear.
Now this ends with, "surely in a flood of great waters they shall not come near him." He switches that quick to those who are iniquitous, to the wicked. It does not seem like there is a switch, but actually this flood of great waters is the Flood of Noah he is talking about. He is talking about all those sinful people before the Flood in Noah's day. The Flood came and their time was gone. They could not change. They could not ask forgiveness. It was done.
And he is saying it is not like that with the people who are part of the covenant of God. They can ask God's forgiveness, and He will give it speedily and deliver them.
And in verse 7, I just want to drop this in here. Maybe you can check it out later. But actually he compares God here to a city of refuge. He is a lot better than a city of refuge. You run to God when you have sinned, and He forgives you immediately. You run to a city of refuge after you have sinned, and you have to stay there for years and years before you get a reprieve because you have to stay there until the high priest dies. It could be so long; it could be a generation before the high priest dies. But if you ask God, run to that refuge, it is immediate and you can make something good of your life after that.
Most of these were written by David. He understood this quite well especially when he was being chased around Judah by Saul, and he had to frequently find hiding places, but he understood that his ultimate hiding place, his ultimate secret place, was God Himself. So he wrote it in the Psalms.