The poem appears twice in the The Lord of the Rings' first book, The Fellowship of the Ring. Firstly, it appears in chapter ten "Strider" in Gandalf's letter to the hobbits in Bree, before they know that Strider (Aragorn) is the subject of the verse. It is repeated by Bilbo at the Council of Elrond. He whispers to Frodo that he wrote it many years before, when Aragorn first revealed who he was.
In Peter Jackson's adaptation of The Lord of the Rings for film, the poem appears in The Return of the King, when Arwen recites the last four lines of the poem as her father Elrond prepares to reforge the shards of Narsil for Aragorn. In the 1981 BBC radio dramatisation, the entire poem is heard in its original context, the letter left at Bree by Gandalf.
The theme of the poem is appearance vs reality. The first line is certainly not a variant and rearrangement of the proverb The Merchant of Venice#Act II, known primarily from Shakespeare's The Merchant of Venice; rather, it is a logical conversion of that statement, resulting (in this case) in a proposition bearing a completely different meaning: Aragorn is vastly more important than he looks. The second line emphasises the importance of the Rangers, suspiciously viewed as wanderers or vagabonds by those the Rangers actually protect from evil. Lines three and four emphasise endurance, while five and six emphasise renewal. Line seven refers to the sword Narsil. Line eight predicts Aragorn's rise to be king of kingless Gondor and vanished Arnor.
Older editions of The Lord of the Rings indexed the poem as The Riddle of Strider. From the 50th anniversary edition of 2005 on, the new, enlarged index by Wayne G. Hammond and Christina Scull list it as All that is gold does not glitter.
The second couplet was added during the following revision:
The lines were changed in stages, with many experimental forms rejected. Christopher Tolkien also suggested that "the Sword that was Broken actually emerged from the verse 'All that is gold does not glitter': on this view, in [the last version cited above] the words a king may yet be without crown, A blade that was broken be brandished were no more than a further exemplification of the general moral.