Joseph seems to have been a naturally kind and caring man, well-suited to Mary. Like her, he did not fly off the handle when he found things out. He was thoughtful, considering the best way to handle the situation. In his day, a woman could receive lifelong shame for becoming pregnant out of wedlock. He desired to "put her away" as quietly as possible without bringing any further shame upon Mary - or himself, for that matter. While he was still mulling it over, an angel, probably Gabriel again, appeared to him in a dream.
Throughout this episode, Joseph is shown to be a humble, pious, obedient man. He takes what the angel says without complaint or even reply. Once he is aroused from sleep, Joseph does just as the angel commands him. The angel's word was enough. The man was convinced. He would comply.
Gabriel tells Joseph almost the same things he said to Mary. It is somewhat odd, though, since it was through Joseph that Jesus would physically claim David's throne, that the angel does not mention that Jesus would be King. This is also interesting because, throughout his Gospel, Matthew constantly mentions Jesus' royal nature. Instead, Gabriel tells Joseph that Mary's Son, whom everyone would think is his Son, would be named Jesus, "for He will save His people from their sins." He also reiterates that He will be God with us and that He was conceived of the Holy Spirit.
These points hint that Joseph was more interested in spiritual matters than physical ones. Perhaps he had not allowed his Davidic lineage to go to his head. He did not need the spur of his adoptive Son becoming King to make him comply. All he needed to know was that God through the Holy Spirit had accomplished Mary's pregnancy, and that the divine Child, in fulfillment of prophecy, would one day save His people from sin.
In His sovereignty, God prepared the perfect couple to raise His Son. They are wonderful examples of submission to God. Even though His intervention in their lives threw a huge monkey wrench into their personal plans, they selflessly said, "So be it, Lord. What would You like us to do next?"