Michael D. Coogan, The Old Testament: A Historical and Literary Introduction to the Hebrew Scriptures, third edition (OUP, 2014), 183-184.
The “law of the king” [Deuteronomy 17:14-20] seems to have been written with specific kings in mind, especially as they are described in the book of Kings. The extravagant acquisition of horses and gold and an enormous harem especially coincides with the description of Solomon’s reign (see 1 Kings 3.1; 4.26; 9.28; 10.14-11.8), but trade and alliances with Egypt are mentioned of other kings, and a harem was an ordinary part of the royal establishment.
The Deuteronomic “law of the king” thus critiques the extravagances of the kings belonging to the dynasty established by David, and also by the ideology attached to that dynasty, in which the king was the adopted son of God and the essential intermediary between God and the people, and in which God had made an unconditional covenant guaranteeing the dynasty in perpetuity….
For the authors of Deuteronomy, writing during the period of the monarchy, although kingship was a divinely sanctioned institution, it was to be severely limited. God’s blessing for the people depended not on the king but on the entire nation’s observance of its covenant with God. The Deuteronomists, in other words, advocated a reform in which the ideals of the premonarchic period would be combined with the realities of the monarchy. Like many of the prophets, they were reactionaries, but their nostalgia for the past was translated into a detailed program for the present and future.