In the world of Middle Earth, the smoking of pipe-weed in pipes is a favorite relaxing pastime for hobbits. Though they did not create the plant itself, they are believed to be the first group to smoke it in pipes. During the events of The Hobbit, Gandalf the Grey is one of a handful of wizards in Middle Earth. Gandalf is the only wizard that socializes with hobbits, particularly with the family of Bilbo Baggins. His friendship with the hobbits and his appreciation of their ability to enjoy the simple pleasures in life lead to him learning to smoke pipe-weed. He becomes quite adept at blowing smoke rings which I believe is the main thing that he does with his pipe. In the film version of The Fellowship of the Ring, Gandalf is shown blowing a sailing ship through Bilbo's smoke rings.