This is one of the ascension psalms and at its heart an enthronement Psalm.
King David danced before the Lord as the Ark of the Covenant was carried up through the hills to the Temple in Jerusalem. After that 3 times a year, the Jewish pilgrims came joyfully playing trumpets (blowing the Shofar) and singing as they climbed the hills to the temple in Jerusalem. This was one of the songs they sang. There were 3 pilgrimage feasts that took place during the year Passover, Pentecost and The festival of Tabernacles (booths).
This Psalm is all about the soverignty of God. It’s been said:
God’s the infinite Ruler of all; Master of the Universe, He is “running the show.” Nothing can prevent His predetermined plan. Nothing takes Him by surprise. If you are crying out to God and can't see his hand at work in your situation, then look at what Satan is trying to do, because he is always one or two steps behind God, trying to catch-up. If you are under attack then know that God has already acted for you and the enemy is retaliating, so rebuke the attack and don't let him steal your joy, your hope or your faith because the truth is that you can REST in God. When you rest, He works. Those who see God’s hand in everything can best leave everything in God’s hand.
This Psalm is also prophetic, in that it points towards a future time when all the Kings and leaders of the gentile nation's acknowledge that God is King of all the earth.
So that at the name of Jesus every knee should bend, in heaven and on earth and under the earth. Philippians 2:10
We saw that already during the festival of Tabernacles (also called Shelters or Booths), this year and for the last several years. That Gentiles have come from all over the world to celebrate with the Jews in Jerusalem. There were parades of almost every nation through the streets of Jerusalem. So while things in the world certainly seem bad enough, God is in control we only see back side of the taprestry of his plan the messy side with all the lose ends but he sees the whole. Prophesy says the world will get worse before it gets better, but we his children can take comfort in His promises, and the knowledge that we know whose going to win in the end.