The gospels of Matthew and Luke present different genealogies of Jesus due to their distinct theological and narrative purposes. Matthew traces Jesus' lineage through Joseph, emphasizing his legal right to the throne of David, crucial for Jewish readers who valued royal lineage. In contrast, Luke traces through Mary, possibly reflecting her biological lineage to David, emphasizing Jesus' universal role as Savior, relevant to a broader, Gentile audience. These differing genealogies serve theological and narrative aims, affirming Jesus' fulfillment of Old Testament prophecies while illustrating his dual identity as both legal heir and universal Messiah.
Why is there a discrepancy in the two genealogies of Jesus? It is too large a difference to blame a copyist, and genealogy was important enough to the Jews that they would know who their ancestors were. There are several different possibilities.
Matthew's genealogy is direct while Luke's included "levirate" marriages. If a married man died childless, his brother was required to marry the widow to provide a son to continue the dead man's line. While it is entirely possible that Solomon would have been willing to add his brother Nathan's widow to his long list of wives and concubines, it is highly unlikely that every single marriage after was a levirate marriage as well.
The two accounts merge within the last three generations. In this theory, Joseph's grandmother first married Matthan and gave birth to Jacob (Matthew 1:15). Matthan died, and she married Matthat and gave birth to Heli (Luke 3:24). Jacob and Heli were half-brothers on their mother's side. Joseph's mother married Jacob, but Jacob died childless. Heli married Jacob's widow, and she had Joseph. If this is the case, Joseph was biologically Heli's son and Matthat's grandson. Legally he was Jacob's son and Matthan's grandson. Thus, legally Joseph would be descended from David via Solomon and the kings of Judah, but biologically he would be descended through David's son Nathan. There is nothing in the Bible to indicate this is true. It was contrived as a possible explanation for Joseph to have two different genealogies.
Luke lied for political reasons. This theory argues that Luke needed to acknowledge that Jesus was a direct descendent of David to fulfill prophecy, but because he wrote to a Greek audience that had endured several Jewish revolts, he needed to de-emphasize Jesus’ relation to David through the line of legitimate Jewish kings. The theory proposes that Matthew's genealogy, written for the Jews, threatened Herod's tenuous hold as king of Israel and was too dangerous for Luke to use. There is no evidence to suggest this viewpoint is correct. For one, if Luke's genealogy is made up, where did he get it from? For another, if Jesus' genealogy was so dangerous, why bring it up at all? Mark and John didn't.
Luke traces Joseph's genealogy through his father, but Matthew traces Joseph's genealogy through his mother. In this view, Jacob would be Joseph's mother's father.
Matthew gives the royal line, while Luke gives Joseph's direct line. This is possible, and since Matthew is written to the Jews, the lineage of Jesus as heir to David's throne is important. But if this other direct royal line existed, it diverged from Joseph's early on, and although Jesus was directly descended from David, it was rather obliquely to the royal line.
Matthew gave Joseph's line, while Luke gave Mary's line. There was no word for "son-in-law" for Luke to use in Luke 3:23, and tradition was that the wife's father would consider his sons-in-law as sons. Matthew, writing to the Jews, would have emphasized Jesus' legal right to David's throne. Joseph would have been directly descended from the royal line of David, but since Jesus was adopted by Joseph, He would have avoided the curse in Jeremiah 22:30 that said none of the descendants of Jeconiah (the last of the direct royal line to rule before the exile to Babylon—see 2 Kings 24) would sit on David's throne. Luke, writing to Gentiles, gave Jesus' biological connection to David through Mary. In addition, Luke 1—2 suggests to Bible scholars that much of Luke's information about Jesus' early life came from Mary. She would have been able to give him her genealogy, and he may have been inclined to honor her by including it.
We don't know exactly why the Gospels include two genealogies of Jesus, but the last explanation—that Matthew's is through Joseph and Luke's through Mary—seems to us the most likely explanation. Either way, Jesus is eligible to sit on David's throne and reign forever (see 2 Samuel 7:12–13).