This week's Parsha, Shoftim, discusses the laws related to a king. The king must not have too many horses or wives, and he must have a Seifer Torah with him at all times.
The של״ה הקודש asks why Shmuel was so upset with the people of his generation for asking for a king. The Torah gives us the laws relating to a king. And the Rambam says that we are obligated to destroy Amalek, build the Beit Hamikdash, and appoint a king when we enter Eretz Yisrael.
The answer was in the manner how they asked for a king. The people asked, שימה עלינו מלך, place a king over us. The key word being עלינו, "on us." In reality, Hashem is supposed to be עלינו, and the king is certainly not meant to upstage Hashem.
The commandment regarding judges and policemen, uses the words, תתן לך בכל שעריך, you shall place them in your gates. It does not say עלינו here. The של״ה הקודש says that the עלינו meant that they would use the king as a means to worship Avoda Zara. This is why Shmuel was angry with the king request. They wanted the king for the wrong reason.
Every request we make of Hashem should be one designed to bring us closer and not more distant from Him. Shabbat Shalom