Both Joseph and Mary were of the lineage of David. The Gospel of Matthew shows it through Joseph’s and Luke shows Mary’s. Jesus’ humanity came through Mary (as a person’s blood “Jewishness” is through their mother). As such, he is the heir to David both legally and physically.
It doesn’t say “ Mary” in Luke 3:23. Show us “Mary” in Luke 3:23.It says “JOSEPH THE SON OF HELI” . Where do you get “Mary”. I hear this from intelligent people. It does not say Heli was the father of Mary. . What happens is that Joseph’s father in Matthew 1 is “Jacob”. There is an error somewhere. No one can prove Mary’s father was Heli. We have documented statement that Heli was the father of Joseph. The apologists run in with “OH !! the father of Joseph is different in the two histories. Who ever wrote Matthew must have meant Heli was the father of Mary”. But that is not what it says so it is an obvious error. This is like trying to prove the sky is blue. The two lineages are different and neither one is relevant because the Father of Jesus is GOD.