Gandalf, Thorin, Bilbo and the dwarves are headed to the Misty Mountains to rescue their treasure from the dragon Smaug. However, there are many dangers on the way to the mountains and few clear, safe paths within the mountains.
In chapter 3, Gandalf warns the company of the importance of keeping to their scheduled journey.
"[It] is very necessary to tackle the Misty Mountains by the proper path, or else you will get lost in them, and have to come back and start at the beginning again (if you ever get back at all)." (ch 3)
The mountains were deceptive, because it seemed like there were many ways around them, over them, and under them.
But most of the paths were cheats and deceptions and led nowhere or to bad ends; and most of the passes were infested by evil things and dreadful dangers. (ch 4)
Some of the mountain passes are guarded by beings or magic. Gandalf and the dwarves were aware of this. Besides the orcs and the necromancer, there were many other dangers in the mountains. Wild animals such as wargs, and mythical beasts such as the thunder giants, threatened them at every turn.
Despite being a wizard, Gandalf is not infallible. He tries to keep the company safe and together, and deal with trouble as it comes. It is very important to him that he give Bilbo his adventures, and help the dwarves return to their home—and their treasure.