Why two different accounts of Jesus's genealogy?

Matthew 1:2-17 16 And Jacob begot Joseph the husband of Mary, of whom was born Jesus who is called Christ Luke 3:23-38 23 Now Jesus Himself began His ministry at about thirty years of age, being (as was supposed) the son of Joseph, the son of Heli If the messianic prophecy was for the christ to be descendant... show more Matthew 1:2-17
16 And Jacob begot Joseph the husband of Mary, of whom was born Jesus who is called Christ
Luke 3:23-38
23 Now Jesus Himself began His ministry at about thirty years of age, being (as was supposed) the son of Joseph, the son of Heli

If the messianic prophecy was for the christ to be descendant of David, and Jesus was born of Virgin Mary, then why all the contradictory geneology of Joseph?
14 answers 14