Quote is taken from J.R.R. Tolkien’s poem „The Riddle of Strider“ from The Lord of the Rings, The Fellowship of the Ring. It is a poem by character Bilbo Baggins in honour of character Aragorn. Quote refers to Aragorns travels as ranger. He wanders, but he knows his mission, knows his purpose, and follows it with determination. J.R.R. Tolkien wrote poem to expand on his novel, to describe Aragorn and to allude to an important piece of plot. You can check the whole poem here.
Often you can see a shortened form of this quote: „Not all who wander are lost“.
It is mostly used by travelers and out of context as it describes purpose which so many people don’t have. Many people use it to justify traveling for the sake of traveling.