When Mary was engaged to Joseph but before they lived together, Joseph discovered that his fiancee was pregnant. The Gospel tells us, “Her husband Joseph, being a righteous man and unwilling to expose her to public disgrace, planned to dismiss her quietly.” He had just “resolved to do this” when an angel appeared to him in a dream, telling him not to be afraid to take Mary as his wife.
Imagine Joseph's state of mind when he found out about Mary's pregnancy. Some saints and theologians have argued that he knew that her Child was of the Holy Spirit and felt himself unworthy of the task of being the foster-father of God. Others maintain that he either suspected Mary of adultery or was completely clueless about how and why she was pregnant. In any case, he must have been confused and upset.
The Greek text, in fact, expresses Joseph's bewilderment. Joseph was unwilling to expose Mary to public disgrace. The Greek for “unwilling” is thelōn, the present active participle of thelō, which means “to wish or will” but also implies a natural inclination of the will. Joseph didn't have to think much about protecting Mary from shame and punishment. He simply had that instinct and chose it actively with his will.
At the same time, however, he planned to dismiss her quietly or privately. The Greek for “planned” here is eboulēthē, which comes from the verb boulomai, meaning “to wish or will” but implying a careful, reasoned consideration. Joseph had apparently been thinking long and hard about his course of action. He had considered the facts as he understood them, weighed the options, and come to a decision. Whether he was acting out of fear and insecurity or a sense of betrayal, he made a deliberate decision to dismiss Mary.
Even after he made this choice, Joseph was still wavering. The English translation suggests that Joseph was set in his decision, but the Greek indicates otherwise. The Greek text reads tauta de autou enthumēthentos or “thinking about these things.” The Greek verb enthumeomai means to think about something, to revolve it in one's mind, to ponder, or to deliberate. In spite of his decision, Joseph was unsettled. His thoughts were turning over and over in his mind, and perhaps he even had difficulty getting to sleep on the night that the angel came and set all his fears, and his troubled mind, to rest.
Sources: greattreasures.org; e-Sword Bible Software; The Ignatius Study Bible by Curits Mitch and Scott Hahn