Gandalf the Grey, an immortal being, is a wizard, one of the five Istari (i.e. "wise" in Kvenian) and a maiar. Before coming to Middle-earth (T.A. 1000) like any other maiar he was subject to the Volar. He can appear both in visible and invisible form.
Gandalf is also known as Mithrandir (i.e. "grey wanderer" in Sindarin) and Olyrin, a name given to him in Valinor. In "The Silmarillion" wisest of the Maiar was Olyrin who dwelt in Lyrien. His ways took him often to the house of Nienna, and of her he learned pity and compassion. This give grounds to believe that Gandalf and Olyrin was one and the Same person. In Middle-earth the wizard sympathized with the weak and those who heard his prayers were awakened from despair and ceased thinking about Evil. In "The Silmarillion" very little is said about the wizard but "The Lord of the Rings" and "The Hobbit" definitely shed more light on his personality.
Gandalf dwells in different parts of Middle-earth. And many are his names in many countries. The elves call him Mithrandir, the dwarves - Tharkun, the haradrims - Incanus. It is hobbits and the Rangers of the North who called him Gandalf. He has a number of nicknames: Gandalf Greyhame, StormCrow, the White Rider, the Grey Wanderer and the Grey Fool. Most likely that by the latter he was "christened" by his ill-wishers as Gandalf is wisdom itself. Like Frodo, he is Tolkien's favourite personage.
Everywhere he is known as a tall robust old man with long grey beard and kind eyes, wearing a pointed hat and a long coat.
Upon arriving at Middle-earth, Cirdan the Shipwright gave him one of the three Elven Rings, Narya, Ring of Fire.
He always carries his staff with him which lights up the way in the darkness and helps to cast a spell. He is armed with the elven-sword Glamdring (i.e. "the shatter of the foes" in Sindarin), forged by the elves and once belonging to the Duke of Turgon. The wizard found it in 2941 T.A. during his journey to the Lonely Mountain.
Gandalf was fighting against Sauron and his servants for about 2 thousand years. It is he who tried to reveal the secret of the Ring, found by Master Baggins in Gollum's cave, and he narrated this story in detail at the Council of Elrond. Little by little the wizard found out the ominous power of the Ring and asked the Rangers of the North to keep an eye on the Shire. Gandalf loves hobbits and always visits their wonderful land. The wizard's fame in the Shire is mainly due to his skill with fires, smokes and lights, adored by all the shire-folk especially kids.
Being a wizard, Gandalf's powers and wisdom are not unlimited. Thus, before going to Orodruin he studies carefully the maps of Middle-earth as well as Gondor's chronicles where he learns about the One Ring. His fight with Balrog turns out to be fatal. Gandalf sacrified himself by battling the fiery Balrog so his friends could escape. He actually died ... but because of his generous act, his spirit was placed in a new body and given even greater powers than before. He becomes invulnerable to any weapon. There is an opinion that before Moria Gandalf was mortal but died from Durin's Bane. And as the fate willed he came back to Middle-earth to accomplish his Cause in the form of Gandalf the White. There was another wizard whose powers where like the maiar's. It was Saruman, a betrayer, who shut him up on the pinnacle of Orthanc. If it were not for the swiftest of the Great Eagles, Gwaihir the Windlord, Gandalf would probably have been Sauron's prisoner till the end of his days.
The Windlord carried the brave wizard to Edoras, the capital of Rohan, where Gandalf chose Shadowfax - the fastest and most tireless horse in Rohan's herd. Indeed, Gandalf could choose not only the right way in the dark corridors of Moria but also the right weapon and the right horse. It is he who predicted that it was only in Frodo's power to make his way to Orodruin and destroy the One Ring.
Gandalf becomes the leader of the Fellowship (before Moria events take place). He bears the responsibility for all the folks of Middle-earth. Only after the end of the War of the Ring would he tell Aragorn that the time had come for Gondor's Sovereign to become the guarantor of peace and order.
During the War of the Ring Gandalf does a lot. He sets free Theoden, the King of Rohan and exiles his servant, Grima WormTongue. So people gain anew a bellicose Theoden and gradually forget him being passive and bewitched by the spells of his Adviser. Also Gandalf overthrows Saruman, breaks his staff into pieces- every wizard's symbol, and frees Isengard along with Rohan's Company. Saruman flees from Hobbiton and Gandalf becomes the Head of the Istari Order.
Gandalf symbolizes honesty and kindness. He doesn't punish Pippin either when the Palantir is stolen or for his conversation with Sauron. It is enough to look into the hobbit's eyes and see - there is no lie there.
Gandalf is an interesting story-teller and a wise advisor. For this very reason Elessar begs Gandalf not to sail over the Sea. The duo of wizard and Aragorn struggles bravely at Minas Tirith and reaches the Black Gates of Mordor. Another interesting episode occurs when Sauron's messenger brings Sam and Frodo's clothes. The messenger of the Dark Lord adduces an ultimatum and affirms that the Fellowship's mission has finally failed. If it were not for the wisdom and eloquence of Gandalf, who did not believe the messenger for a moment, the allied army would probably have lost its competitive spirit and would not have won.
In 3021 Gandalf and Frodo left Middle-earth as the third Age, the Age of fight with Sauron, was over. And, therefore, Gandalf the White fulfilled his mission successfully. The time of wizards comes to an end and the future of Middle-earth is entirely in the hands of people - that is Gandalf's main idea which fully characterizes the arrival of a new Age, the fourth one. Gandalf left Middle-earth but he would stay in the hearts of common people for ever.