When Mary told Joseph that she was pregnant, he would have known that he was not the biological father. He decided to break the engagement, but in a manner that would not bring shame to Mary. He was set on a course of action that was based in justice and love – at least from his current vantage point.
Once Joseph had decided to break the engagement, God sent a messenger – and angel – to speak with him. The angel confirmed that Jesus was of the Holy Spirit. As a result, Joseph obeyed God’s instructions, married Mary and did not consummate the marriage until after Jesus’ birth.
We know that Joseph trained Jesus in carpentry, took Jesus and Mary to Jerusalem for the Passover each year and provided good spiritual instruction.We do not know, however, how long he continued in his role as Jesus’ earthly father as he is last mentioned when Jesus was 12 years old.
Joseph demonstrated a strong faith that Jesus was the son of God. He endeavoured to do the right things in the right way for Jesus, and had many recognisable traits. These included that he was a man of integrity and was sensitive to God’s guidance, being willing to do God’s will even though there would be probable adverse consequences for him personally.
We can learn from him, in particular, that God honours integrity (especially faith in God and God’s word), and that social position is not important in God choosing to use us.