This fact has been under-appreciated by Matthew commentators: Mary was
already legally Joseph's wife and so, in being legally bound to the line of
David, her offspring would also be in that family. This is confirmed by the
ending of the genealogy: Ίακώβ δε εγέννησεν τόν Ίωσήφ τόν άνδρα Μαρίας, έξ ής
εγεννήθη Ίησοϋς (Matt 1:16). While this is well recognized as an odd ending to
a genealogy (which Matthew will go on to explain), it does indicate that Mary
was in the family line by betrothal already and Matthew has already given
examples of Davidide-by-marriage women in his genealogy. At conception Jesus is
already in the family of David, but it will be up to Joseph whether or not the
baby and his mother remain part of the family.
. . .
The "taking" (παραλαμβάνω) of Mary describes step two in
Jewish marriages of this period, when the wife would move into the husband's
home. Numerous English translations and commentators make the mistake of adding
"as" to the translation, "to take Mary as your
wife." Mary is already legally his wife according to Matthew. It is in
Joseph's purview to divorce Mary, but the command is to continue in the marital
relationship, with the taking of Mary into his home being stage two in their
marriage. After the dream and the editorial insertion of the formula quotation,
Joseph does "take his wife" (1:24). With this act, Mary and her son
are solidly in the family line of David through the completion of their
marriage: "Joseph's taking his wife-i.e., taking her home in
wedlock-echoes v 20 and assures Jesus' place in the Davidic line." (H.
Daniel Zacharias, Matthew’s Presentation of the Son of David [T&T
Clark Biblical Studies; London: T&T Clark, 2017], 54-55, 57)