“If, after you have entered the land that your God יהוה has assigned to you, and taken possession of it and settled in it, you decide, ‘I will set a king over me, as do all the nations about me,’” (Deuteronomy 17:14)
The law of the King is weird. It is not a mandatory Mitzvah, it is said if you want a King, like the others have, be my guest and appoint one. Laws are rarely up to us to decide whether we want to fulfill them or not. In the Torah doing what the other nations are doing is never a good thing. And Kings here, are doing what the other nations do.
The Bible clearly does not like kings or rulers, politics seems to be a compromise. The ideal society does not need a king or any kind of ruler. It is ruled by our ability to listen and obey what God wants us to do.