Let's admit it, Lord of the Rings is the mac-daddy of all subsequent fantasy books. (Were there any fantasy books before Lord of the Rings?) Lord Voldemort is Sauron. Dumbledore is Gandalf. Harry is Frodo. James is Bilbo. Wormtail is Wormtongue. And so on.
If you read that last paragraph carefully, you might think that my knowledge of fantasy books is limited to Harry Potter. Since that's pretty much accurate, I'll have to change my thesis statement: "The Lord of the Rings is the father of the Harry Potter books."
One of the resources I read while writing my college thesis paper pointed out that all the Harry Potter characters had doubles; that is, just about every character has a double that corresponds in characteristics, social status, destiny, and challenges--except that the double is opposite in, shall we say, wickedness-status.
Think about the Lord of the Rings characters in this way. It's especially noticeable about halfway through Book Two of The Fellowship of the Ring: Legolas and Gimli, Merry and Pippin, Frodo and Sam, Aragorn and Boromir.
Gandalf's double is not in the fellowship; his double is Saruman, instead; someone who is totally opposed to the fellowship. This sets him apart from the other members of the fellowship. Not only is he a wizard (duh), but his double is outside the social group they're all traveling in and working with. It's also one of the reasons he dies at the beginning: he doesn't have a companion within the circle, and so he has to be removed from the circle. However, his double is still among the living, and so he must return from the crack of Khazad-Dum. Gandalf himself says that he is Saruman: "I am Saruman; Saruman as he ought to have been." Contrast that with Saruman, who only diminishes and decreases. By the end of the Lord of the Rings, Saruman has become so pathetic that he thinks it's a success to have taken over the Shire (come on! the Hobbits are short! Merry and Pippin grow to become the tallest Hobbits ever at 3'6"!!) and becomes so base that Wormtongue, his pathetic trembling toady, kills him and cuts his throat.
By the end of The Fellowship of the Ring, Boromir is dead, which leaves Aragorn free to pursue his destiny. As Boromir grew weak and needy, craving and desiring the Ring, Aragorn grew in strength and majesty. Ironically, he was one who could have mastered the Ring, but he had the wisdom to turn from that temptation and become a glorious king of Men instead.
Legolas and Gimli grow closer together as friends throughout the rest of the story and develop a respectful relationship. They fight battles together, help rebuild Minas Tirith, and even travel together to see beautiful caves (Gimli's most favorite place to be, as a dwarf) and the ancient forest Fangorn (where Legolas feels most at home). Instead of sneering at each other for being different, their respectful friendship permits them to visit each other's favorite haunts and appreciate those haunts, if only out of respect for each other.
Merry and Pippin both set out from the Shire unaware of the journey they would take, both are taken captive by the Urukhai, both become allied with different kings of Men (and miss each other terribly during their separation from each other), clean the Shire upon their return, and their bond of brotherhood becomes so strong that they become housemates at the end of the story.
Frodo's double is Sam. They are both from the Shire, both love the simple life, and are both Hobbits, but their relationship is one of master-servant instead of being true comrades. Frodo's double is also Gollum; at the heart of their relationship is the need for and dependence on the Ring. It's the Precious. The conflict between Sam and Gollum comes from this complexity: Sam is jealous of Gollum's influence over Frodo; Frodo and Gollum share a relationship with the Precious which excluedes Sam; and Sam is not Frodo's social equal, but his servant. Gollum, meanwhile is sick from the Ring. Gollum is Frodo's double, but he is also his own double. The Ring has damaged his personality to such an extreme that he has split in two, which enables him to be his own mirror in the story.
How does the Frodo/Sam/Gollum/Smeagol destiny end? Gollum and Smeagol die in the fires of Mount Doom, leaving Frodo free to be reunited with Sam. However, Frodo himself has been damaged by the Ring and its power, and Sam falls in love with and marries Rosie. Both of these influences serve to isolate Frodo from Sam, and something must be done. Frodo's miserable and isolated in the Shire--and so he leaves, along with Bilbo (another loner!) and Gandalf (also a loner). All the characters who have become isolated from their doubles don't have a purpose in the mortal world anymore, and their destinies lie elsewhere.
This story is brilliantly crafted on so many levels, and this theory of corresponding chracters is only one way Tolkien draws us in, weaves a story around us, and leaves us with that satisfied feeling as we turn the last page.