He's basically engaged to Mary, and he finds out she's pregnant. He could have said something, and she would've been stoned to death (oops) at worse, and shamed/shunned at the least (if I understand correctly). He didn't say anything.
He could have divorced her. He thought about it, actually. Apparently, he decided to sleep on it before making a decision and while he slept an angel came to him in a dream and explained everything. He didn't divorce her. Which might mean people thought Jesus was born out of wedlock, and Joseph was willing to live with that.
Those things aside, Joseph was a very obedient man.
When my mom was training my sisters and I in obedience as kids, she would tell us that true obedience means you do it "immediately, completely and without complaint." We weren't supposed to dilly-dally, do things halfway, take the easy way out or whine about it. I'm not at all saying I learned this very well or quickly... there's a reason those words have stuck with me so long (I must've heard them a lot).
Joseph's mom must've taught him this, too (I wonder what the Hebrew words for "obey immediately, completely and without complaint" are). He must have learned that lesson well because his response to God's angelic directions is noteworthy.
Near the end of Matthew 1, the angel tells Joseph, among other things, to call the baby's "name Jesus, for he will save his people from their sins." And almost as an afterthought, in the last verse of Matthew 1 it says of Joseph, "And he called his name Jesus."
It doesn't end there. in 2:13-14, the angel comes back and in a dream (Joseph sure seems to sleep a lot! That, or heaven and earth must be on different time zones...) tells Joseph to take Mary and Jesus and move to Egypt. No telling when or if they'd come back. And look at the wording:
...an angel of the Lord appeared to Joseph in a dream and said, "Rise, take the child and his mother, and flee to Egypt, and remain there until I tell you, for Herod is about to search for the child, to destroy him." And he rose and took the child and his mother by night and departed to EgyptThe wording of the angel and the description of what Joseph did are parallel. Authors word things intentionally. I take this to mean that Joseph obeyed "immediately, completely and without complaint".
Joseph wasted no time. He didn't wait until it would 'be a good time', he 'rose' and took them 'by night', which sounds to me like he woke up after that dream, packed up, and left.
Joseph didn't stop someplace convenient between Israel and Egypt. He went all the way, and waited for God's command.
Joseph didn't complain about God uprooting he and his family (at least, the complaints weren't recorded, so that's my guess. Plus, it fits nicely with the phrase I learned as a kid).
And then in verses 19-21-- Same thing! Same parallel wording. Same obedience.
The obedience that married Mary.
The obedience that named Jesus.
The obedience that moved to Egypt.
The obedience that returned to Israel.
Immediately. Completely. Without Complaint.