The idea that God is King not a projection of human Kingship upon God; human kinship came about in history due to ruling power man received from God. God as king rules by his mighty power.
"The Lord is King,
robed in majesty...
More powerful than the roar
of many waters,
than the breakers of the sea,
powerful in the heavens
is the Lord." (Ps 93:1,4)
When the Israelites left Egypt under the leadership of Moses God was their King. They became his people and they promised to obey the Commandments. Moses was the channel through whom God ruled his people. This endured till the time of Judges.
Samuel the prophet lived c.1020-1000 B.C. When he became too old to rule, he appointed his sons as judges but they ruled unjustly. So the people demanded a king like other nations. He realized that they were rejecting God as their king, but after consulting God, he granted them their request and Saul became the first king of God's People. Saul was a bad king driven by his jealousy of David.
When God rejected Saul a King, Samuel anointed David as King. David was not so holy but was a man of faith and courage who repented for his sins and was humble under God's mighty hand. David desired to build a temple for God but God rejected his offer because he had shed much blood. However, through the prophet Nathan, God made David a promise, "Your house and your kingdom shall endure forever before me; your throne shall stand firm forever." (2 Sm 7:16)
In the history of Judah and Israel, one king followed another and most of them turned out bad. After Solomon's death, the kingdom was split in two (Judah and Israel).
Hoshea, the last king of Israel, was imprisoned by the Assyrian king for conspiracy and failure to pay tribute and the people deported into exile in 722B.C.
Zedekiah, the last king of Judah, Rebelled against Babylon so Nebuchadnezzer in 586 B.C. destroyed the Temple of Jerusalem and exiled the Jews to Babylonia. Zedekiah was brought before the king with with his sons and princes. The king slew his sons and princes, blinded Zedekiah and cast him into a Babylonian prison until his death.
The Jews perceived that the evil that fell upon them and their kings was due to the evil they had done in disobeying God. The king embodied the destiny of his people, so when the king failed to live up to God's Covenant, the people were also under God's judgment with him.
With the failure of Israel Kings, the exile and the unstable political period after the exile, the Jews began to look forward to a king and kingdom promised to the House of David.
The sad Jeremiah sits amidst the ruins and Jerusalem and new hope arises in his heart and he writes,
"Behold, the days are coming says the LORD,
when I will raise up a righteous shoot to David;
As king he shall reign and govern wisely,
he shall do what is right in the land." (Jr 23:5)
Christ the King