Throughout the Lord of the Rings, Tolkien sets the characters to many tests. Some of them fail. Some of them, like Boromir, stumble but rise again in the end to do the right thing. Some, like the Radagast, appear to become distracted. Only a few pass each test, gaining power and wisdom as they do. In his Letters (156 To Robert Murray S. J.), Tolkien says that Gandalf is the only one of the wizards who passed all the tests. The last test, the battle with the Balrog, cost him his life.
In the Unfinished Tales, Tolkien says the wizards were sent by the Valar as emissaries and that: