John Henry Hopkins Jr., an American clergyman, wrote both the words and the music in 1857. The carol tells the story of the Magi, the wise men from the East who follow a star to Bethlehem, and it is sung especially around Epiphany, on 6 January.
The Gospel of Matthew does not say there were three of them, nor that they were kings: the number comes from their three gifts, gold, frankincense and myrrh. The carol gives each gift its own verse, in the voice of the king who brings it - gold for a king, incense for God, and myrrh, a bitter perfume, for the death to come - before a last verse that looks to the resurrection.
This transcription: John Henry Hopkins Jr., "We Three Kings of Orient Are" (1857), as printed in Hollis Dann, Christmas Carols and Hymns for School and Choir (New York: American Book Co., 1910), p. 11, archive.org christmascarolsh00dann_0, page n14; checked against Henry H. Sweets, Christmas Carols (Louisville, 1923), p. 10, archive.org christmas-carols-smyth-1855, page n11: verse in E minor and refrain in G major; left hand by GOONS Studio.
Transcribed by GOONS Studio from the original work, which is in the public domain.