Those who consider pure democracy to be the best form of government are often encouraged by I Samuel 8, wherein the Israelites ask for a king, and God says:

“Hearken to the voice of the people in all that they say to you; for they have not rejected you, but they have rejected me from being king over them” I Sam 8:7

One would think that God is rejecting monarchy as a whole, preferring Israel to be ruled by the Judges. Yet one cannot jump so quickly to this conclusion. God did not reject monarchy absolutely, but only at that time. In Genesis 49:10, He states:

The scepter shall not depart from Judah,

nor the ruler’s staff from between his feet,

until he comes to whom it belongs;

and to him shall be the obedience of the peoples.

Since Judah had been promised the scepter, no one but a member of the tribe of Judah could be the King of Israel. Until the generation of David, however, no member of the tribe of Judah was fit to fulfill the role of King. The Book of Deuteronomy forbids illegitimate children from participation in the public life of Israel for ten generations, and Judah’s children were illegitimate. David was a member of the eleventh generation from Judah, and thus able to occupy the throne of Israel.

This is why God says that Israel had rejected Him when they wished for a King, because He had ordained that a certain man be the King, and this man was not ready yet.

See Deacon Joseph Gleason’s posts here and here for a more complete explanation.