From The Lord of the Rings wiki
Gandalf the White
Gandalf the White is the resurrected form of the wizard Gandalf the Grey, sent back to Middle-earth by Eru Iluvatar to lead the forces of the West against Sauron.
After sacrificing himself to defeat the Balrog of Morgoth in the depths of Moria, Gandalf was sent back to complete his mission. He returned with greater authority and power, replacing Saruman the White as the head of the Istari. His presence became essential in rallying the kingdom of Rohan and guiding the Fellowship, including Aragorn, Legolas Greenleaf, and Gimli, through the final stages of the War of the Ring.
Role in the War of the Ring
As Gandalf the White, he played a pivotal role in the liberation of King Theoden from the influence of Saruman and Grima Wormtongue. He subsequently coordinated the defence of Gondor during the Battle of the Pelennor Fields. His leadership was instrumental in drawing the attention of Sauron toward the Black Gate, providing the necessary diversion for Frodo Baggins and Samwise Gamgee to reach Mount Doom and destroy the One Ring.