Gandalf's status as a ring-bearer, as well as his successful completion of his mission, earned him his place in the Undying ...
Gandalf was busier between The Hobbit and The Lord of the Rings than most people realize, but his movements are a mystery to most fans.