What did King David do as king?
I don't know if you are asking for a summary of David's accomplishments or what the duties of a king were in David's time. Below is a quick overview:
The Accomplishments of King David
David successfully defeated the enemies of Israel, thus creating the ability for his son, Solomon, to reign in peace. "After this it came to pass that David attacked the Philistines and subdued them. And David took Metheg Ammah from the hand of the Philistines. Then he defeated Moab. Forcing them down to the ground, he measured them off with a line. With two lines he measured off those to be put to death, and with one full line those to be kept alive. So the Moabites became David's servants, and brought tribute. David also defeated Hadadezer the son of Rehob, king of Zobah, as he went to recover his territory at the River Euphrates. ... When the Syrians of Damascus came to help Hadadezer king of Zobah, David killed twenty-two thousand of the Syrians. Then David put garrisons in Syria of Damascus; and the Syrians became David's servants, and brought tribute. The LORD preserved David wherever he went. ... He also put garrisons in Edom; throughout all Edom he put garrisons, and all the Edomites became David's servants. And the LORD preserved David wherever he went" (II Samuel 8:1-3, 5-6, 14).
It was David who made Jerusalem the capital of Israel. "And the king and his men went to Jerusalem against the Jebusites, the inhabitants of the land, who spoke to David, saying, "You shall not come in here; but the blind and the lame will repel you," thinking, "David cannot come in here." Nevertheless David took the stronghold of Zion (that is, the City of David)" (II Samuel 5:6-7). He also moved the center of worship to Jerusalem as well. "So they brought the ark of the LORD, and set it in its place in the midst of the tabernacle that David had erected for it. Then David offered burnt offerings and peace offerings before the LORD" (II Samuel 6:17). It was David's desire to build a permanent structure for the house of God, but he was not allowed to do so. "But God said to me, 'You shall not build a house for My name, because you have been a man of war and have shed blood.'" (I Chronicles 28:3). However, he did design the house that his son Solomon eventually built."Then David gave his son Solomon the plans for the vestibule, its houses, its treasuries, its upper chambers, its inner chambers, and the place of the mercy seat; and the plans for all that he had by the Spirit, of the courts of the house of the LORD, of all the chambers all around, of the treasuries of the house of God, and of the treasuries for the dedicated things; ... "All this," said David, "the LORD made me understand in writing, by His hand upon me, all the works of these plans."" (I Chronicles 28:11-12, 19).
The Duties of an Israelite King
The king served as the highest court in the land. "The king establishes the land by justice, but he who receives bribes overthrows it" (Proverbs 29:4). Elders of a community and the Levites served as local judges, but all matters could be appealed to the king for a final ruling. "So David reigned over all Israel; and David administered judgment and justice to all his people" (II Samuel 8:15).
The king was also the war leader for the nation. This was common in Israel and the other nations of that time. "It happened in the spring of the year, at the time when kings go out to battle, that David sent Joab and his servants with him, and all Israel; and they destroyed the people of Ammon and besieged Rabbah. But David remained at Jerusalem" (II Samuel 11:1). David was supported as king by the war lords of Israel. "All these men of war, who could keep ranks, came to Hebron with a loyal heart, to make David king over all Israel; and all the rest of Israel were of one mind to make David king" (I Chronicles 12:38). In one of David's psalms, he said, "Blessed be the LORD my Rock, who trains my hands for war, and my fingers for battle" (Psalm 144:1).
Appointments to various governmental positions were also done by the king. "Also Jehoiada appointed the oversight of the house of the LORD to the hand of the priests, the Levites, whom David had assigned in the house of the LORD, to offer the burnt offerings of the LORD, as it is written in the Law of Moses, with rejoicing and with singing, as it was established by David. And he set the gatekeepers at the gates of the house of the LORD, so that no one who was in any way unclean should enter" (II Chronicles 23:18-19).
Because God gave Israel their body of law, a king could not actually create a law. He could decree regulations to help manage the keeping of the law. Instead of making law, the king was ultimately responsible for the nation's keeping of the law of God. Josiah was considered a great king because of his strong will to keep the law. "Now before him there was no king like him, who turned to the LORD with all his heart, with all his soul, and with all his might, according to all the Law of Moses; nor after him did any arise like him" (II Kings 23:25).
Even though David was king of Israel, the people of Israel looked upon their kings as only a local ruler. The Lord God was the king of all kings. "For the LORD is our Judge, The LORD is our Lawgiver, The LORD is our King; He will save us" (Isaiah 33:22).