Jesus is the Messiah promised to come through the line of Abraham and David. Son of David was also a messianic title of the time. Son of Abraham identifies Jesus as a descendant of the patriarch of Israel.
Jews at the time were expecting the Messiah to be a king, who would re-establish the Jewish Nation and end Roman rule. Jesus was not the earthly political and military king they expected, but he was of kingly descent. Matthew follows the royal line of David through to Joseph. Matthew specifically refers to David as David the King, to signal the start of the royal line.
This genealogy is full of sinners. David took another man’s wife. Solomon turned from God to pagan worship and worldly lusts. Tamar deceived her father-in-law Judah into sleeping with her. Rahab was a prostitute. Bathsheba committed adultery with King David. The kings of Israel turned from God often. Everyone is a sinner, and everyone needs grace. Jesus is the redeemer of his own lineage.
The Genealogy is separated into three sections of fourteen generations covering the history of Israel. The first section, from Abraham to Jesse, describes the birth and growth of the nation. The second section describes the generations of a rising and flourishing kingdom, and the lists the royal line of Kings from David to Jeconiah, which ultimately meets its demise at the hands of the Babylonians. The royal and influential families were deported. The final section exhibits the line of David after the fall of the kingdom. Joseph, though a descendant of the king, had no throne, but lived under Roman rule. This allowed for the humble birth of Jesus.
Joseph is not the natural father of Jesus. This should not be of any concern. Matthew establishes a legal fatherhood to Joseph. Adopted children have taken on the name and lineage of their father throughout history. Joseph was chosen by God to raise Jesus. For all purposes, Jesus was referred to and known as the son of Joseph, as God ordained. It should also be noted, that the genealogy in Luke, through Mary, demonstrates a bloodline relation of Jesus to David. However, the true kingship of Jesus comes from God. This line of kings was insufficient to produce a messiah, because they were all full of sin. God had to send his own, perfect son.