Put yourselves in his place and consider how you would feel if...
You were in love with a beautiful young lady and were engaged to her only to find out SHE'S PREGNANT!!!! (and you know you're not the father!). All the wonderful plans and dreaming of having her as your wife suddenly die and disgrace replaces them. Consider that.
In the night while you are spinning in your mind about the sudden turn in your life path, you dream and an angel of God is there....a huge shinning, beautifully powerful angel (Gabriel was one of the highest angels...an arch angel...the same as Lucifer was before his fall). He begins speaking directly to you an unbelievable message. And the message is actually telling you something to do regarding your future. You find out who the father is. And you are directed to take on an important role in a story only God could create. And that he would be the father of "God come in the flesh"!!!
Despite your situation and the disgraceful and judgmental thoughts/talk (whispers) that surround you, you quickly embrace the angel's directions and leave with your pregnant wife-to-be (there is no hiding the baby in her womb now) and go to your hometown to fulfill a required government law. All of the sudden, you are no longer living for your own needs...you are now a to-be-husband and a soon to be father (you know in a matter of days)!!!
Probably you meet and see others childhood friends and their family that have shown up in your hometown too. You struggle with not being able to explain what is happening but you determine to "obey God" over and over. It's really hard on you.
In your desperation to find a suitable place for your to-be-spouse (as any good father would do) to have this "special baby", the best you can provide is a cave animal shelter. There is no one to help deliver the baby....perhaps you even have to help deliver this baby and see your to-be-wife unclothed for the first time in this setting. Awkward at best.
Then there were those poor scraggly, smelly strangers that just "showed up" specifically to see your new baby (and you hadn't told anyone yet)....and they knew, like you, Who this baby is! Imagine the goose bumps...the joy (that had not been in your situation for months).
Imagine your thoughts turning to what it would be like to take your wife and new baby back to Nazareth...and then in sleep (again!) there is "that" angel and now he's saying to live somewhere else...not just another city, but a different country because the head government official has ordered soldiers to find and kill your baby! Imagine alarming feelings and urgency as a new father and husband! Imagine having to make hugely important decisions all of the sudden and second guessing yourself at every turn because you want to do what is best for your new family.
I've given you some of Joseph's story...but there is more in Luke and you might want to let the Holy Spirit lead you on to more wonderings....continue to journey to Christmas....
it is good for us to "consider Joseph"....a real man of God.