At that time there was no king in Isra’el; a man simply did whatever he thought was right.
The concept of Israel putting a king over itself is nuanced. In Samuel we learn of the unrighteous largesse of the King: how he will conscript the men and levy taxes, among other things. Samuel is hurt, but The LORD clarifies that it is Him that Israel is rejecting. That being said, the laws of the king given to Moshe are designed to make the king the exemplary Jew. He is required to write his own copy of the Torah and carry it with him at nearly all times. He may not use his position to indulge in his flesh, in short he is to be an example for all Israel to do as he does, to love and serve The LORD with all his heart, soul and strength. That is the aspect of kingship Israel lacked in the time of The Judges.