2 Samuel 16:12
“Perhaps the LORD will look on my misery and return good to me instead of his cursing this day.”
David had a great understanding of God. He let that govern his behavior. Most rulers would have granted the soldiers request to kill the mocker (verse 9). He knew that God was loving and just. Part of this was justice for David's wrongs. It appears he knows this. He is being patient in this discipline.
I Thessalonians 5:18 says, "in everything give thanks; for this is the will of God for you in Christ Jesus." Unless we are reaping the results of sin, we should give thanks in all things. Our lives are in Christ. He uses all situations to glorify His name. It may be to share Christ with someone. Or possibly to share godly character or love to others.
Acts 16:30 gives us an example, "Now about midnight Paul and Silas were praying and singing hymns of praise to God, and the prisoners were listening to them." This would have frustrated most. They used it as an opportunity to glorify God. We should do the same. Of course, we seek means to be released, but we can glorify Him in the process.
God will do something. In acts 30, He prompted an earthquake which gave them an opportunity to share Christ. He will do something with us in our misfortunes. David knew that God was merciful and in control in his tough time. The same is true with us.
While we seek to remove ourselves from this situation, don't act unbecomingly. That is unless the law is being broken. Like Corrie Ten Boom felt justified to lie to the Nazi's looking for the jews they were hiding. Proverbs 26:5 says, "Answer a fool according to his folly, lest he be wise in his own conceit." The rules are different with a fool. We need wisdom. Normally, do not return evil for evil. Be wise when dealing with a fool. Jesus did not tolerate the pharisees. Not when they were persecuting Him, but when they were harming others. He condemned them for unjust practices in the temple, for keeping healing from others and so on.
We will run across those who don't play nice. Don't engage them, as David didn't. Be the better person. Jesus taught in parables to keep from tossing pearls before swine. He knew some wouldn't accept, but mock. The truth was in their grasp, but they weren't interested. They seek to undermine, so they are blind to the truth.
We can test the situation by tossing out a seed. If received, then continue. If they mock, then don't toss pearls before swine. While love is a high aim, honoring God is higher. We aren't to enable evil. It's like giving someone a ride to an abortion clinic. We are being helpful to the person, but are assisting in evil.
Lord, help us to be thankful in all times, but to be wise with fools.