It is the wisdom of God to bring good out of evil. The ultimate example of that is the Son of God being put to death by men, but God accomplishing the salvation of sinners through it. In the life of a believer the Lord also brings good out of bad. In Psalm 4, we see the Lord turning the distress of David into spiritual benefits for David.