The second, third and fourth verses of the song go into greater detail on the individual gifts that they brought:
Gold was a gift for a King. Prophecies foretold that Jesus would be King of the Jews, and that His reign would last forever. The wise men came to pay homage to the newborn King, who was so great that His birth and reign had been prophesied for hundreds of years.
Frankincense was a gift for God. Prophecies also indicated that Jesus would be no ordinary King, but rather God in human form. Frankincense is basically the hardened sap from a Boswellia tree (see the Wikipedia article for more details). It is often used in incense, and when it is burned, it lets off fragrant smoke that rises into the heavens (provided there aren't walls and a roof in the way). It is used by many traditions in worship. In India, they use it for medicine, and some people use it as a mosquito repellent.
Myrrh was a gift for the Messiah, who would one day, about 30 years later, die a painful death to save us from our sins. Like frankincense, it is a kind of sap, this time from the Commifora variety of trees. In several ancient cultures, it was used as an embalming spice. It was likely one of the spices the ladies brought when they came to put on Jesus' body and instead discovered that His tomb was empty. Myrrh is also used in many cultures (including China and India) for its medicinal qualities.
The final verse is more or less a summary of the gifts and praise to God. It points out that He is "King [thus the gold] and God [frankincense] and sacrifice [myrrh]." It then goes on to say "Alleluia, alleluia! [הללו יה, Hebrew for "Praise the Lord!"] sounds through the earth and skies."
The lyrics are here. The song was written by John Henry Hopkins, Jr. in 1857 for a Christmas pageant featuring his nephews and nieces. It was also featured at another pageant at New York City's General Theological Seminary, where he was the music director at the time. It was published in 1863. (See the Wikipedia articles on the song and Hopkins for more on that.)
---
As for the timing and location of the visit of the Magi...they are often portrayed as being at the stable, all ready for the group shot with the shepherds, sheep, goats, cattle, Mary, Joseph, and baby Jesus in the manger. Not so. Matthew specifically states that they came to the house, not the stable, where Jesus was. The census was over, and many people had gone home. Apparently, Mary and Joseph had stayed in Bethlehem and found a house to live in by this point. I'm sure they got out of the stable as soon as possible, and they probably didn't want to make the difficult journey back with a newborn baby in tow. Jesus could have been as old as two years by this point, judging from the fact that Herod ordered all the boys age 2 and younger to be killed (based on information he had gotten from the Magi).
---
One thing I find interesting about We Three Kings is that the title is a bit of a misnomer. There were probably more than three of them, and they were not kings. The Bible doesn't actually say how many wise men came, so the traditions draw the number from the number of gifts that they brought. Traditionally, their names were Balthasar, Gaspar and Melchior. According to Spanish tradition, Melchior came from Europe, Gaspar came from Asia, and Balthasar came from Africa...which is interesting, since the Bible states that they came from the East, and Europe and Africa are northwest and southwest, respectively, of Israel. In any case, I don't know how many of them came. I just know that they brought at least three gifts.
So if they weren't kings, who were the wise men? The Bible calls them Magi (or "wise men"; the singular form is magus), an order of advisers to the King of Persia dating back centuries before the birth of Christ, to the days of their founder Zoroaster. They studied the stars and interpreted their meanings. Today we would call them astrologers. It is likely that the advisers of King Nebuchadnezzar, in the prophet Daniel's time, were magi. Some even believe Daniel was a magus. Interestingly, the term is also translated "sorcerer" in the book of Acts. The word magic is related to it.
This tells me a lot about the people to whom God chose to announce His coming. They were the last people anyone would think of announcing the arrival of God in flesh. Shepherds were the lowest of the low in Jewish society. They were regarded as dirty outcasts, only fit for raising sheep to be used in sacrifices. Astrologers have long been regarded as evil occultists in religious circles. (The apostle Paul even struck a magus with blindness, due to his opposition to the Gospel.) When He grew up, Jesus pointed out that "It is not the healthy who need a doctor, but the sick. I have not come to call the righteous, but sinners to repentance" (Luke 5:31-32). The shepherds probably had very little, if any, education, and they likely didn't know much about the prophecies or even the Lord, but one visit from an army of angels, and they became some of the first evangelists. The Magi were highly intelligent individuals who had the ancient texts and the interpretations of the stars at their disposal. They were obviously very rich, considering the gifts that they brought. They believed that the stars foretold the future. As believers in Christ, we often tend to shun people who believe, dress or behave differently from us...but that's exactly who God chose to announce His coming to. Jesus died to save them. Shunning and avoiding them is an insult to His sacrifice. I'm not saying we should do what they do, but we need to show them His love, not scorn. Judging is God's job, not ours.
Oh...one more thing. Why am I posting this now? I meant to post it on January 6, which is Three Kings' Day, also known as Epiphany, the traditional end to the Twelve Days of Christmas (the day the singer received a whopping 78 gifts - 23 birds, 55 people, and 5 rings). In his novel Notre Dame de Paris (which was later translated into English and renamed The Hunchback of Notre Dame), Victor Hugo tells about a counter-celebration that the non-Catholics celebrated on January 6, the Feast of Fools (or, as the Disney version calls it, Topsy Turvy Day). On a related note, I find it interesting that in English, both the French musical Notre Dame de Paris and Disney's version of The Hunchback of Notre Dame involve Quasimodo being crowned "the King of Fools." But Hugo wrote his novel as a criticism of hypocrisy he saw in the Catholic Church, and the French versions of the novel and the French musical have them crowning Quasimodo "the Pope of Fools." Once again, people translating something as "King" where that's an inaccurate translation.