The LORD is far from the wicked but he hears the prayer of the righteous.
Many people believe that God answers all prayers alike which is why so many turn to Him in a last ditch plea of desperation. When all other human means have been exhausted, people believe that God will bail them out even though they have done nothing to even acknowledge Him before their time of need.
The truth is that God answers the prayers of the righteous before those of the wicked. We should be careful and not take this concept too far however. Righteous people do not always have their prayers answered the way they like and God sometimes responds to wicked people for reasons that are entirely His own.
For this reason, we shouldn’t falsely assume that a person lacks faith or is guilty of some great sin if God does not answer their prayers the way they would like. The book of Job is full of accusations of wrongdoing on Job’s part when he was in fact a righteous man.
The principle that we should take away from this verse is that it is better to be righteous rather than wicked. God is much more likely to answer the prayers of a righteous person than a wicked one. More than simply a matter of righteousness however, a righteous person is more likely to pray for something that is God’s will rather than a selfish prayer.