In Summary:
Matthew opens his Gospel with the genealogy of Jesus. It is likely a representative genealogy, meaning that the facts are accurate but some generations may be left out or compressed. How does that happen? There is precious little difference in the words for son/descendant and father/ancestor, because culturally there is some compression on the issue. One is not just a "father's son" but also a "grandfather's grandson" but all fall under an "ancestor's descendant." The rest of this debate is better suited to the "nerd note" section.
The opening genealogy traces Abraham down to Jesus, passing through David and the deportation to Babylon. Matthew moves on to the events surrounding the birth of Jesus, though the nativity itself gets only a passing mention in Matthew 1:25. Which, by the way, is an interesting side note about Christmas chaos: there's hardly any clear Scripture about what happened that day/night. To what end do we get so worked up about it?
Matthew does highlight Mary's virginity three times in eight verses. That indicates significance, and that the Virgin Birth was not something created out of nothing by the church later on. How do we know that? The antiquity of Matthew is a reason--Matthew is written sometime between 60 and 100 AD. This is the range that works with history, with one's theology pushing towards the varying ends of the spectrum.
In Focus:
Let's put Joseph in focus today, looking at Matthew 1:18-25. Matthew provides the facts first: Mary is pregnant, she and Joseph are not married yet. There's much not said here, like how she "was found to be with child." That phrasing hints that there was more going on here than just Mary knowing she was pregnant. There's also the side note of how TV networks refused to use the word "pregnant" in the early days, but would use "with child." I think that was on I Love Lucy. As if the meaning is any different. (Although, thinking about it, I wish we use "with child" all the time. It's much clearer about what is happening.)
Mary already knows the facts while Joseph is in the dark. She is pregnant by the Holy Spirit, with details clearer for us in Luke 1:26 and following than they are here. Joseph, though, does not know what has happened. We have the benefit of history, looking back at the whole picture. He's living it.
And he likely doesn't know what to do at this point. His options, not knowing about the divinity of Mary's unborn child, are the she either loves another or has no morals. Those are his choices for how this happened, and to his credit, he's neither jealous or angry. Apparently, that is, though I doubt Matthew recorded the first words out of Joseph's mouth. Instead, he wants to simply release Mary from their marriage. If she's in love, she can chase that. If she's immoral, he's out of having to deal with it.
Joseph, though, didn't have the full picture. There was an option that he never thought of, because the idea that the prophets of old would come true for his day was extreme. Instead of Joseph's righteousness on display, Mary's being "with child" would show the righteousness of God Himself. She was, indeed, a virgin and the one who bring forth a son called Immanuel.
In Practice:
Making it a given that Jesus came that way one time, and will return triumphant the next time, what do we do with this?
First, we acknowledge this: our own experience is not enough. Our imaginings and wonderings will get us so far, but never far enough. We cannot conceive of all the ways that God fulfills His Word.This is actually why many formulations of doctrine are negative: it is often very clear from Scripture what God said He will not do, but that leaves open many things. Further, Joseph could see in Isaiah that a virgin would have a child...but how was he to figure it would be his future wife? Let God work through the ways God works, being whatever part we can be.
Second, know this: our righteousness is limited. It is based on our understanding, which can be flawed. Be committed to walking in obedience with God--Joseph was. Once God made Mary's situation clear, Joseph followed God fully.
Third, be cautious about judging the ups and downs in another's life. If Mary's condition is known, and Joseph married her anyway, then he took on public scorn alongside her. His "righteous man" status would have fallen in the public eye, for he couldn't wait until the wedding, could he? But we see that privately, not only was he righteous at the beginning, he held on through the rest of the time to allow not only a virgin conception but a virgin birth.
Keep your body and will fastened to the righteousness of God.
In Nerdiness:
1. Genealogy of Jesus in Matthew is different from the one in Luke. We have to deal with that--the traditional Joseph in one, Mary in another, may not be right. But it's a start. There's also a possibility of tracing legal heads of household vs. actual parents, but I can't find the reference work on that one. Suffice it to say that both are accurate, so somehow it works.
2. Genealogy of Jesus: the inclusion of some of the women is important, as are their stories. Learn and read.
3. Genealogy of Jesus: note the symbolism of 14, 14, 14 to make the generations.
4. Authorship: How do we know Matthew wrote Matthew? Mainly through early church history. It's also logical, as there's precious little reason to scrape up the former tax collector as a potential author when others, like Peter, could have been suggested.
5. Date: most of the date debate is inconclusive. Does Matthew write about the Temple's destruction as prophecy? I think so, and I think that makes his Gospel pre-70 AD. Others disagree.