8 Now that the Virgin was of the race of David is indeed from these things evident; but wherefore he gave not her genealogy, but Joseph's, requires explanation. For what cause was it then? It was not the law among the Jews that the genealogy of women should be traced. In order then that he might keep the custom, and not seem to be making alterations from the beginning, and yet might make the Virgin known to us, for this cause he has passed over her ancestors in silence, and traced the genealogy of Joseph. For if he had done this with respect to the Virgin, he would have seemed to be introducing novelties; and if he had passed over Joseph in silence, we should not have known the Virgin's forefathers. In order therefore that we might learn, touching Mary, who she was, and of what origin, and that the laws might remain undisturbed, he has traced the genealogy of her espoused husband, and shown him to be of the house of David. For when this has been clearly proved, that other fact is demonstrated with it, namely, that the Virgin likewise is sprung from thence, by reason that this righteous man, even as I have already said, would not have endured to take a wife from another race.
There is also another reason, which one might mention, of a more mystical nature, because of which the Virgin's forefathers were passed over in silence; but this it were not seasonable now to declare, because so much has been already said.
Source: Homilies on the Gospel of St. Matthew (New Advent)