Our Lord Jesus became related to the human family by taking our nature through His mother Mary. Mary’s genealogy, as traced by Luke, leads back to David through his son Nathan (Luke 3:23). 

Joseph is here styled “the son of Heli,” that is, the son of Eli, Mary’s father, by marriage, or legally; or as we would say, son-in- law of Eli. By birth, Joseph was the son of Jacob, as stated in Matthew 1:16, while Joseph’s genealogy, as given by Matthew, traces also back to David through his son Solomon (Matthew 1:6-16). Joseph having accepted Mary as his wife and adopted Jesus, her son, as though he were his own son, this adoption would entitle Jesus to reckon Joseph’s genealogy; but such a tracing back to the family of David was not necessary, because his mother came also of David, by another line. Thus, the seeming discrepancy is due to the fact that Luke gives Mary’s genealogy while Matthew gives the genealogy of Joseph. The difference in the number of generations from David to Christ need not be considered as remarkable. It would be remarkable had they been the same. 

Additional Resource:
Christian Questions Podcast
Episode #1312: “How Do We Know Jesus Is the Promised Messiah? (Part I)”
Jewish skepticism and key Old Testament identifiers of the Messiah
CQ Rewind Show Notes