Asaph experienced the opposite of what this proverb says. He complained that wicked people knew no troubles, while he was suffering day after day (Psalm 73:1–28). Thus, this proverb is not a straightforward one. It is one of the “riddles of the wise” (Proverbs 1:6).
The book of Proverbs itself speaks in many places of the troubles that may befall righteous people. The best way to understand a proverb such as this one is to see it as a general principle: the righteous can avoid many of those troubles that sin brings into the lives of wicked people.
21 No ill befalls the righteous, but the wicked are filled with trouble.