Mary, Joseph, and Jesus stayed in Bethlehem for two years and moved into a house. The Magi or the Wise Men, arrived two years after Jesus’s birth. Thus they were not at the cave. It is reasonable to assume that there were three Wise Men because they present Jesus with three gifts. The Magi were from present day Iraq or Iran. Three Gentile men started following a star that eventually brought them to the house where Mary, Joseph, and the two year old Jesus lived (see the second chapter of the Gospel of Matthew).
The star was supernatural and cannot be logically or astronomically explained. Many people much smarter than I have tried: astronomers, scientist, theologians. However, I want to offer you a theory I received (I believe) from the Holy Spirit a few years ago.
It is recored in all four Gospels that angels were involved in the announcement of the birth of Jesus and all though out the Bible they are associated with the delivery of messages from God to man, and many other activities in the Spirit Realm.
I did a study of angels a few years ago. They are mentioned almost 300 times. They all have different jobs…only some are messengers. Some are called seraphim, cherubim, The Hose of Heaven and (among other names) Stars. I present you the Star of Bethlehem, a Spirit Being assigned to herald the birth of the greatest man ever, the son of God. So large and so bright he was seen as a celestial object and brought the Magi from far off Iraq.This beautiful being shown over the stable and moved with the Christ and His family until they went to Egypt to escape the army of Herod.