"But when he had considered this, behold, an angel of the Lord appeared to him in a dream, saying, "Joseph, son of David, do not be afraid to take Mary as your wife; for the Child who has been conceived in her is of the Holy Spirit. She will bear a Son; and you shall call His name Jesus, for He will save His people from their sins.”
Joseph doesn't rush to make a decision about ending his betrothal to Mary. He waits, and ponders what to do. We don't know how much time passes, but one night -- in a dream -- his answer comes. "An angel of the Lord" appears to him and calls him "son of David". This is a confirmation of his lineage; Joseph is a descendant of King David. And then to Joseph the angel reveals a most amazing plan. Joseph is to go through with the marriage. He is to become Mary's husband. She is carrying the Son of God and Joseph is to name him "Jesus", meaning "Jehovah is Salvation". But salvation from what? Salvation from sin. Jesus will save His people from their sins.
The Jews expected a Messiah to save them politically, but their greatest need was not salvation from the Romans. It was salvation from their sins. It is still the greatest need of all th world today. And its fulfillment is met in Jesus. He "brings salvation to everyone who believes: first to the Jew, then to the Gentile." (Romans 1:16 NIV)