The song is a reference to Frodo's quest to return the One Ring. The girl mentioned in the lyrics of Ramble On, as well as Over the Hills and Far Away is the One Ring.
Other Led Zeppelin songs, such as The Battle of Evermore make strong references to Tolkien's work, as they were a strong influence on Robert Plant.
Here's a pretty good write up of the Led Zeppelin/Tolkien connection, which discusses Ramble On:
... the band dips into the realm of Tolkien with "Ramble On". The song starts out with a set of soft bass notes provided by Jones, backed by Bonham creating the soft beat by patting on his knees. "Leaves are falling all around / time I was on my way!" tenderly sings Robert Plant. His vocals begin to tell the saga of young Frodo Baggin from The Lord of the Rings story. Frodo, the young Hobbit, has unfortunately been given the somber task of carrying the One Ring, the ring that contains the power to destroy all of Middle-Earth. During his journey towards Mordor, Frodo stays in Rivendell, the Elvin city, where the Council of Elrond decides what is to be done with the Ring. Frodo and his best friend Samwise enjoy their stay very much but they know that they have to "Ramble on,/ And now's the time, the time is now/ To sing my song. / I'm goin' 'round the world, I got to find my girl." The girl mentioned in the song, as well in another song "Over the Hills and Far Away" is not actually a female, but the Ring. Throughout the saga of Frodo, Sam, Aragorn and the others, the Ring is referred to as a beautiful lady, and is often called "precious". Throughout Tolkien's books, the characters sing songs as they travel across the lands on their journey. Frodo also searches for "Queen of all his dreams," Plant sings out. Galadriel, the Elvin Queen of the forest, is most likely this queen that he is searching for. The section of the song that points directly to The Lord of the Rings is "T'was in the darkest depth of Mordor/ I met a girl so fair, / But Gollum, the evil one crept up/ And slipped away with her". The direct references to Mordor and Gollum are sure and intriguing signs that this song is about Frodo, yet part of it does not make sense. Frodo was not in Mordor when he was given the Ring, "the girl so fair," but he was "in the darkest depth of Mordor" when he met Shelob, the giant Spider, who is far from fair. But it was in Mordor that Gollum took the Ring of Power from Frodo....