The "Magi" that the Bible mentions as part of the Christmas story are often called "wise men" because they were scholars whose knowledge of both astrological science and prophecy helped them figure out that the unusually bright star they saw shining over Bethlehem pointed the way to the Messiah, the one they believed was destined to save the world: Jesus Christ.
An evil king named Herod also knew of the prophecies, and was determined to hunt young Jesus down and kill him. But the Magi were warned about Herod in a dream so they could avoid going back to him and telling him where to find Jesus.
The Bible doesn't say whether or not it was an angel who delivered the message to the Magi in the dream. But believers say that it's miraculous that the Magi all had the dream that warned them to stay away from King Herod.
The Bible records in Matthew 2:1-3 that: "After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem and asked, 'Where is the one who has been born king of the Jews? We saw his star when it rose and have come to worship him.' When King Herod heard this he was disturbed, and all Jerusalem with him."
Many historians think that the Magi came eastward to Judea (now part of Israel) from Persia (which includes such modern nations as Iran and Iraq). King Herod, who ruled Judea at the time, would have been jealous of any competing king who would have drawn attention away from him -- especially one who people thought was worthy of being worshiped. The people of Jerusalem would also have been disturbed at the news that a greater king had come to rule over them.
The story continues in Matthew 2:4-6 of the Bible: "When he had called together all the people’s chief priests and teachers of the law, he asked them where the Messiah was to be born. 'In Bethlehem in Judea,' they replied, 'for this is what the prophet has written: 'But you, Bethlehem, in the land of Judah, are by no means least among the rulers of Judah; for out of you will come a ruler who will shepherd my people Israel.'"
The chief priests and teachers of the law referred King Herod to a prophecy from Micah 5:2 and 4 of the Torah that says: "But you, Bethlehem Ephrathah,though you are small among the clans of Judah,out of you will come for me one who will be ruler over Israel,whose origins are from of old, from ancient times ... He will stand and shepherd his flock in the strength of the LORD, in the majesty of the name of the LORD his God. And they will live securely, for then his greatness will reach to the ends of the earth."
The Bible continues the story in Matthew 2:7-8: "Then Herod called the Magi secretly and found out from them the exact time the star had appeared. He sent them to Bethlehem and said, 'Go and search carefully for the child. As soon as you find him, report to me, so that I too may go and worship him.'"
Although King Herod said that he intended to worship Jesus, he was lying, because he was already planning to murder the child. Herod wanted the information so that he could send his soldiers to hunt down Jesus in hopes of eliminating the threat that Jesus posed to Herod's governing authority.
The story concludes in Matthew 2:9-12: "After they had heard the king, they went on their way, and the star they had seen when it rose went ahead of them until it stopped over the place where the child was. When they saw the star, they were overjoyed. On coming to the house, they saw the child with his mother Mary, and they bowed down and worshiped him. Then they opened their treasures and presented him with gifts of gold, frankincense and myrrh. And having been warned in a dream not to go back to Herod, they returned to their country by another route."
The three different gifts that the Magi presented to Jesus and Mary were symbolic: The gold represented Jesus' role as the ultimate king, the frankincense represented worship to God, and the myrrh represented the sacrificial death that Jesus would die.
When the Magi returned to their homes, they avoided going back by way of Jerusalem, since they had each received a warning in their dreams not to go back to King Herod. Believers say that the dream was miraculous because all the Magi separately received the same warning that reflected Herod's true intentions (which they hadn't known about before). In the very next verse (Matthew 2:13), the Bible says that God sent an angel to deliver a message about Herod's plans to Joseph, Jesus' earthly father, so some people think that an angel also spoke to the Magi in their dreams.