The angel told Joseph that Jesus would save people from their sins.
Gabriel
Joseph was told not to divorce Mary, as that was what he was thinking of doing.
The angel who instructs Joseph to flee to Egypt is identified in the Gospel of Matthew. After the visit of the Magi, an angel appears to Joseph in a dream, warning him of King Herod's plans to kill the child Jesus. Following this divine guidance, Joseph takes Mary and Jesus and escapes to Egypt to ensure their safety.
The angel appeared to Joseph in the Bible before the birth of Jesus.
The Angel said that the Child is from God and Joseph was not to divorce Mary for supposed infidelity. In another dream, the Angel told Joseph to take Mary and Jesus to Egypt to avoid King Herod's order to kill all boys under age 2.
The angel Gabriel appeared to Joseph in a dream to tell him about Mary's pregnancy.
Joseph and Mary were betrothed to each other. Joseph had to go to Bethlehem to be registered because he was an ancestor of King David. Mary, who was with child went with him. Joseph was the step father of Jesus and God had ordained that Joseph and Mary raise Jesus after His birth. They became a family and Joseph was the father figure.
Here Jesus was not warned to flee, but the angel warned Joseph in a dream.
The angel visits to Joseph played a significant role in the events surrounding the birth of Jesus by reassuring Joseph of Mary's pregnancy and guiding him to accept his role as Jesus' earthly father. The angels helped Joseph understand the divine nature of Jesus' birth and encouraged him to protect and care for Mary and the baby Jesus.
Baby Jesus, animals, Mary, Joseph and angel
Joseph was told that his fiancee was going to get pregnant with the power of the holy spirit. and to name him Jesus and that he would be the savior of the world.
----------------------- In Matthew's Gospel, Joseph knows this because an angel appeared to him in a dream and told him about Jesus. In Luke's Gospel, Joseph knows this because Mary told him that an angel had appeared to her and told her about Jesus.