The third and fourth lines concern Aragorn's heritage, while the remaining lines describe his destiny.
The second line, perhaps one of the lines from Tolkien's work most often quoted out of context, refers to Aragorn's travels.
The first line is clearly a re-working of the traditional proverb ' All that glitters is not gold', shifting its meaning. Bilbo himself recites the poem at the Council of Elrond when Boromir expresses doubts about Aragorn's claim to be the Heir of Isildur. Aragorn indeed later quotes the first two lines, not knowing the poem is in the letter, and this does help to confirm his identity.
The poem thus appears in that context as a means of identifying Aragorn. In that letter, it appears as part of a postscript reminding Frodo to make sure that the ' Strider' he meets is 'the real Strider'. The poem is first given in the letter left for Frodo by Gandalf in Bree.