Psalm 1 & 2 combine to introduce the Book of Psalms. In Ps.1 God speaks to each individual and calls us to choose the path of righteousness. In Ps.2 God speaks to the Nations who actually unite to oppose Him and His anointed King and calls them all to repentance and blessing.
Though David is not mentioned as the author of Ps.2 the Bible tells us He wrote it in Acts 4:25. King David is a type for God's Son, the true King Jesus Christ. This is called a Royal or Messianic Psalm because it foretells how the world of Religious and Political, Jew and Gentile leaders united in the rejection of Jesus, His resurrection and exalted coronation at God's right hand in Heaven as King, Lord, and Christ (Acts 2:22-38; 4:25-26; 13:33, Heb. 1:5; 5:5).
David shows his amazement at the foolishness of the revolt because they are going up against God Himself! The voices of David, the Nations, and God, are all recorded to warn world leaders who oppose the Kingdom of God and His people. They proclaim His sovereign power, wrath, and mercy.