Though they are a prominent part of Nativity sets and Christmas pageants, the magi only make one appearance in the Gospels, in Matthew 2: 1-12. (Though we commonly call them “kings,” the term magi originally referred to members of the Persian priestly caste and later became used for those possessing great knowledge and wisdom. Matthew presents them as astrologers.)
In Matthew’s account, the magi see a new star (which was believed to indicate that a new ruler had been born) and travel to Jerusalem looking for the new king. King Herod, of course, is troubled to hear of a possible rival to his power, and asks the magi to report back to him when they have found the child.
Matthew shows the magi traveling to Bethlehem and prostrating themselves before the baby Jesus, offering him the now-famous gifts of gold, frankincense, and myrrh.
They have a dream warning them not to go back to Herod, so they return home by a different route. This presumably delays Herod from finding Jesus, thus giving Mary and Joseph time to flee to Egypt once Joseph receives his own warning in a dream (Matthew 2:13-15). This account is the only interaction that the magi have with the Holy Family in Scripture.