Both Matthew and Luke were writing predominantly for a Jewish readership, and in Judaism, your credibility was determined by who your ancestors were. Luke was keen to demonstrate to his Jewish audience that the Messiah had arrived, and with this in mind he laid down a demonstration that Jesus was a direct descendant of David.
David was born in Bethlehem, the youngest of eight sons of Jesse and great grandson of Boaz and Ruth. He is believed to have been born around 1085 BC and died in his 70th year in 1155 BC (though other theories put it all 30-50 years later). He was the second king of the two kingdoms (Judea and Israel) united in monarchy and whose reign over Judea took him from 1055 - 1047 BC, and over both kingdoms from 1047 - 1015 BC. He was a passionate man who sometimes got life catastrophically wrong. He was intent upon claiming the kingdom of Israel and ridding the land of the plague of Philistines making Israel an independent state for the first time. Early in his rule he captured the Jebusite city of Jerusalem and organised the arrival there from Cariathiarim the Ark of the Covenant, making Jerusalem the centre of Jewish worship and its political centre. It still is.
When he became King it is said by some sources that there were 339,600 men under his command. At the census 1,300,000 were enumerated capable of bearing arms. A standing army, consisting of twelve corps, each 24,000 men, took turns in serving for a month at a time as the Jerusalem garrison. The administration of his palace and his kingdom demanded a large retinue of servants and officials. David exercised the office of judge, though Levites were later appointed for this purpose, as well as other minor officials.
After the Ark had been brought to Jerusalem, David undertook the organization of religious worship. He wrote many of the psalms to be used during worship, and the sacred functions of the liturgy were entrusted to 24,000 Levites; 6,000 of these were scribes and judges, 4000 were porters, and 4000 singers. He arranged the various parts of the ritual, allotting to each section its tasks. The priests were divided into twenty-four families; the musicians into twenty-four choirs. Preparatory to building a proper temple (it was held in a tent during David's reign) David began to acquire treasures and materials, and describing to his son Solomon a plan for the building and all its details.
He is shown as a just monarch and prophet with a talent for writing, capable of being a warrior king when called upon. Strategically he was either very lucky or very clever.
Luke had to take great pains therefore, to establish that Jesus was a direct descendant of David, which is why the gospel opens with the chronology it does. What isn't clear though, according to some commentators, is why, if the expected Messiah had to come down the Davidic line did Luke draw the line down the maternal route ending at Mary, instead of drawing it down the paternal line ending at Joseph. During the Diaspora while Romans were killing as many Jewish men as they could, it was established that the blood line should come down maternally so the Jewish nation wasn't wiped out, but in awaiting the Messiah it was the paternal line that mattered. According to ancient Jewish tribal law, the Messiah must come from the Tribe of David down the paternal line. Joseph was of the Davidic line, not Mary, and as Joseph was only betrothed to Mary and not united in marriage, Jesus wasn't actually at the time of His birth (following the tradition of the story of the virgin birth) from the Davidic line because He wasn't related to Joseph. The only way that Jesus could have come from the Line of David is if Jospeh and Mary were married, not betrothed, at the time.
Luke would also have known that to his audience, the Messiah (Maschiach Heb.) means 'Anointed', and that this was different from 'Saviour' (Moshiah Heb.) and that the Anointed One was to be a political leader descended from King David, well versed in the Law and the Prophets, devout, and be a charismatic leader. Characteristics which are easily argued that Jesus had.
Clearly this is a little difficulty which later editors to the gospels may have not considered, but, this is the reason why King David appears in the Orthodox tradition. He was, is, and will always be a VERY important man.
If you are interested, further information and his full biography is here.