The theme of this chapter is about "God's protection" and can easily be seen in verse 5. Pouring oil on the head was considered refreshing in that culture (see Psalm 23:5; 45:7; 133:3). If a righteous man offers you constructive criticism, it is a good thing. It would be foolish to refuse it. So verse 5 is saying that if a righteous man strike me--it is a kindness; let him rebuke me--it is oil on my head. My head will not refuse it.
The question comes up. How do we know if such advice is good? Again, we compare it with biblical principals. God cares about us and that is why He sends people into our lives to keep us on the right track. When we get such rebukes from others who fear God, we should not curse them because they put us down, but appreciate the good gesture.
David remains resolute in his opposition to evil as noted at the end of verse 5 when he states that his prayer is ever against the deeds of evildoers and then in verse 6 that their rulers will be thrown down from the cliffs, and the wicked will learn that his words were well spoken. This is a reminder that we have both kinds of people in our lives, that is, people who want to help us and people who want to harm us. These words are strong but remember we are reading a prayer for God's protection. We are reading about asking a God who knows all things to work against those who are trying to accomplish evil things in this world. It is important to pray for repentance for those who are wasting their lives turning from and rejecting God. I see in these verses the requests for God to make those who turn from Him to realize the errors of their way.
Realistically, sometimes in order for people to turn to God, their ego has to die a hard death. I am convinced miracles are not enough to get people to turn to Him. People must to want to change from the inside. If such people see their own aspirations fall apart, it may get them to realize that trusting in God is the only way to live in this world.
When David prays for rulers to be thrown down from cliffs, he may or may not be literally speaking of his enemies. His point is that if those people bent on doing evil fail, it may get others to realize the error of following them and their lifestyles.