This was the second dream or vision that Joseph had received from God. Joseph's first dream had revealed that Mary's child would be the Messiah (1:20-21). His second dream told him how to protect the child's life. Although Joseph was not Jesus's natural father, he was Jesus's legal father and was responsible for his safety and well being.
Divine guidance comes only to prepared hearts. Joseph remained receptive to God's guidance. How willing are you to listen to God? When you know what God wants, are you willing to follow his instructions?