Matthew 1 clearly asserts the virginal conception and divine origin of Jesus, "God with us," "of the Holy Spirit" (Mt 1:18,20,23). The principal concern, however, is to explain Jesus' human origin to both Jews and gentiles. The very first verse states the purpose of the two chapters: "The book of the origin of Jesus Christ, the son of David, the son of Abraham" (Mt 1:1).
Jews are shown that the Son of God is the Messiah promised to the royal line of David. Chapter 1 demonstrates this through the genealogy of Joseph, his legal father. Chapter 2 confirms it by the geography of his birth in Bethlehem, the town of David, even though he was raised in Nazareth.
With respect to gentiles, not always fully accepted by the Jewish Christian community, there is the reminder that the Messiah is also "the son of Abraham," who inherited God's promises for all. "I tell you, many will come from east and west and sit at table with Abraham, Isaac, and Jacob in the kingdom of heaven, while the sons of the kingdom will be thrown into the outer darkness" (Mt 8:11-12). Matthew 1 breaks protocol to include gentiles in the genealogy. In Matthew 2 the gentile magi search for the newborn king to adore him, while the religious leaders of Jerusalem show no interest in seeking him and actually become accomplices of Herod's plot to kill him.
The genealogy that follows the opening verse does not totally agree with that of Luke 3. In fact, even the name of Joseph's father differs in the two: Jacob (Mt 1:16) or Heli (Lk 3:23), although their fathers' names are similar, Matthan and Matthat respectively. There is clearly a certain artificiality in Matthew's presentation of the genealogy in three groups of fourteen: "So all the generations from Abraham to David were fourteen generations, and from David to the deportation to Babylon fourteen generations, and from the deportation to Babylon to the Christ fourteen generations" (Mt 1:17). It was common practice at the time to allow certain inclusions or exclusions to better serve the purpose of the writings. This purpose would be somewhat different for the different audiences to which Matthew and Luke were writing. Since Matthew is so concerned to draw parallels between the New and Old Testament Josephs, it is not surprising that their fathers are both "Jacob," a name used only of the patriarch throughout the whole of Scripture. There is no discrepancy whatsoever regarding Jesus' Davidic descent, nor any room to doubt the historicity of Joseph, his legal father, who belongs to the substance of the tradition shared by the independent sources of Luke and John.
From the time of King David, who lived a millennium before Christ, God's covenant with his chosen people was made through the king of Israel, anointed by God as shepherd of Israel, heir of the promises made to Abraham, and unifier of all the tribes into one people. When David decided to build a temple, God promised him a descendent, a son of God, who would establish his reign forever (2 Sam 7:12-16). Not too long after David's reign, the kingdom was divided and eventually it crumbled, but the messianic hope in the promise of the promised new son of David did not leave the people. The New Testament teaches in many places that Jesus is the "Son of David" fulfilling that promise, and establishing his Church as the new Israel for all peoples of the earth. More than any other, Matthew's Gospel emphasizes the title "Son of David" (Mt 9:27; 12:23; 15:22; 20:30,31; 21:9,15; 22:41-45). His very first task, then, is to begin his Gospel by showing how Jesus is of the royal line of David in accord with the promise.
Matthew's genealogy thus revolves around David, whose name occurs in the first verse (Mt 1:1), ends the first and begins the second of the three divisions (Mt 1:6-7), and is repeated in the concluding summary (Mt 1:17). This summary verse makes a point of repeating that the number of generations in each of the three parts is fourteen, a number which results from taking the sum of the numerical position of the Hebrew alphabet of DWD (4+6+4), the consonants for "David." David is the only one given the title "the king" (Mt 1:6).
The genealogy almost tediously repeats the formula A begot B, and B begot C, down to the very end when the pattern is clearly interrupted. Joseph does not beget Jesus, but is the husband of Mary of whom Jesus "was begotten." Other irregularities, such as the inclusion of four women in the genealogy help prepare for this most significant, final irregularity. This interruption in the pattern is explained by the following verses 18-25, the story of Joseph's vocation, which is strictly connected to the genealogy. The introductory verses (Mt 1:1,18) to both the genealogy and this following section contain the same Greek noun génesis "origin." The connection has often been obscured, since this same noun has often been translated as "genealogy" or something similar in verse 1, and as "birth" in verse 18. In the passage on Joseph's vocation, the angel of the Lord addresses Joseph as the "son of David" (Mt 1:20) and clarifies the mysterious verse 16, by showing how one born of the Holy Spirit is also the Son of David through Joseph, and thereby qualifies to be the promised Messiah.
In Jewish practice, biological fatherhood was not the only way to pass on genealogical descent, since adoptive fatherhood was no less valid. Matthew presents Joseph as the legal father who transmits Davidic descent without being the biological father. Joseph's fatherhood is much more than "adoptive," however, since he was already betrothed to Mary in a juridically binding manner at the time of the miraculous conception. By taking Mary into his home before Jesus' birth, Joseph was merely continuing with the normal final phase of Jewish marriage. The child he accepted as his own at the angel's bidding was not born to any other human father. Conceived not by any adulterous affair, but by the Holy Spirit, Jesus is certainly the legitimate offspring of Joseph's legitimate wife. Joseph is his only possible human father, and he is legally so because he is Mary's husband: "Jacob begot Joseph, the husband of Mary, of whom Jesus was born, who is called Christ" (Mt 1:16). Joseph is called to name the child, since this is a natural consequence of continuing the marriage and forming a household with his pregnant wife. Jesus the Christ, the divinely conceived Savior, can be recognized as the promised Son of David because Joseph is son of David.
Taken from http://www.osjoseph.org/stjoseph/scripture/part1sec2.php