In Palestine, the betrothal period was akin to our sense of engagement but was somewhat more binding.
The couple is considered married but have not yet come to live together. An indiscretion of this nature requires a formal divorce and thus public knowledge.
Joseph seeks to spare Mary this public disgrace, but God intercedes and alerts Joseph to the real identity of this child which is in her 'by the Holy Spirit'.
For Matthew, this is the most important point of his infancy narrative.
The child Jesus is the fulfilment of the ancient prophecy that the maiden will conceive 'God with us.' God has freely chosen to come among people.
The second important point in this text is Joseph's response. The anguish and turmoil he must have felt is overcome by his trust in God's ways and he obeys. He simply 'did what the angel told him to do.'
Through his trust and acceptance of God's will, human history will never be the same because 'God-is-with-us'.