Nestled within several chapters of 1 Chronicles that describe David's wars, 1 Chronicles 18:14–17 explains the purpose of those wars: To establish Yahweh's order of justice in Israel, an order of justice that David himself administers and mediates. Having conquered Philistia, Moab, Ammon, and Edom, David reigns over “all Israel” (v. 14) and his reign is a righteous one.
Justice and righteousness mean conformity to Torah. David fought obediently, refusing to lay hands on plunder (18:8; cf. 1 Chronicles 2:17) and refusing to multiply chariots (18:4; cf. Deuteronomy 17). He is also Torah-observant in peace. In Old Testament perspective, that means that David gives equal justice to all, which is especially an advantage to the weak and vulnerable who, lacking resources of their own, rely on the king's protection (cf. Psalm 72).
“Doing justice and righteousness” (mishpat, tzedaqah) is explicated with a list of David's officials in the military, court, and temple; officers of war, law, and worship. Though the king “does justice” as the representative of the just God, the king carries out his justice through subordinates. Mishpat (like many similar terms in ancient languages) implies the establishment of order, and so doing justice involves establishing of institutions and appointing personnel. David, in short, does justice by setting up an orderly bureaucracy.
David's justice is numerologically represented in the list of names in verses 15–17. Seven officers are mentioned by name: Joab is over the army, Jehoshaphat (“Yah judges”) is recorder or court historian, Zadok and Abimelech are priests, Shavsha is secretary, Benaiah is over David's personal guard, and David's sons are “chiefs.” David is the “eighth” over the entire kingdom. A seven- or eightfold bureaucracy hints at a new-creational theme. The administrators also represent Israel: Fathers are included to identify the administrators, so the list of seven/eight leaders is a list of twelve personal names. It is a twelvefold court for the twelve tribes.
That may not excite justice advocates, but orderly administration is essential to doing justice. Think of the roadblocks that a clogged, corrupt, or stagnant bureaucracy throws up, and you have an idea of why David's justice involves appointing men to head up sectors of his kingdom.