The nature of Gandalf’s character is revealed when he refuses the Ring. When Frodo offers the Ring to Gandalf, Gandalf says:
Do not tempt me! For I do not wish to become like the Dark Lord himself. Yet the way of the Ring to my heart is by pity, pity for weakness and the desire of strength to do good. Do not tempt me! I dare not take it, not even to keep it safe, unused. The wish to wield it would be too great for my strength.