Why was Shmuel upset that Yisrael requested a king? The Torah says "v'Amarta Asimah Alai Melech k'Chol ha'Goyim Asher Sevivosai; Som Tasim Alecha Melech" (Devarim 17:14, 15)! They were commanded, after entering the land, to appoint a king, wipe out Amalek and build the Beis ha'Mikdash (Sanhedrin 20b)!
Rashi (like R. Yehudah in Sifri Shoftim 17:14): They said "like all the nations 1 ." Radak (5) - i.e. "v'Nilcham Es Milchamoseinu" (verse 20). Refer to 8:7:1:1.
Radak (5), Malbim, citing R. Nehurai in Sifri Shoftim 17:14): They requested in order to serve idolatry 2 - "Gam Anachnu k'Chol ha'Goyim" (verse 20).
Radak (5), Malbim, both citing Sanhedrin 20b): The elders asked properly "Melech Leshafteinu." The ignoramuses messed up, and said "Gam Anachnu k'Chol ha'Goyim" (verse 20).
Radak (5): They did not request for the Mitzvah, rather, as a complaint. Had they said 'in order to judge us properly', he would not have been upset.
Malbim #1: A kingdom gives (a) unity, (b) consistency, and (c) absolute ability. This is for nations that conduct according to nature, and Yisrael when their shade (Divine protection) went away. Then they needed a king for war. When Hashem did wonders for them and conducted them based on Hashgachah, they did not need a king - "va'Shem Elokeichem Malkechem" (12:12). At such a time, to request a king trespasses Malchus Shamayim. When they are under nature, it is a Mitzvah or Reshus to request a king. Hashgachah clung to Shmuel; Hashem brought thunder on Pelishtim (7:10, and for a Siman to Yisrael - 12:17) at Shmuel's desire. This is why Chachamim said, they asked at the wrong time.
Malbim #2: It impinged on Shmuel's honor to request a king "Leshafteinu." This implies that they want a better judge, for he did not judge them properly. It would have been fine to ask for a king to fight their wars.
For what did Shmuel pray?
Radak: He prayed for prophecy, to know what Hashem will say [about their request].