Gandalf faces many challenges throughout the tale of The Lord of the Rings. The Gates of Moria pose a number of these.
First, Gandalf faces the decision of entering Moria at all. The preferred route is a pass through the mountains, but the evil wizard Sauruman makes passage effectively impossible. Not wanting to bring the Fellowship into the mines he knows to be extremely dangerous, he offers the choice to Frodo who elects to go through Moria.
Gandalf then leads the group to the Gates of Moria and encounters the challenge of opening them. The instructions carved over the Gates are a riddle that stumps the wizard. Here Gandalf's wit is challenged and Frodo solves the problem again.
Gandalf's mind is challenged again while leading the Fellowship through the maze of tunnels and shafts. "I have no memory of this place," he says. A wizard is nothing if not an all powerful mind and Gandalf must face the issue of his own slipping.
His final struggle in Moria is with the balrog. This "demon of the ancient world" is the last foe that stands between the Fellowship and escape from Moria, and is a classic struggle between good and evil. To ensure the safety of the rest of the group, Gandalf "sacrifices" himself to direct battle with the balrog. The two fall "through fire and water" and Gandalf "dies" as a result of the fight. However, with his return in the subsequent book in the series, he returns all the more powerful and thus completing the metaphor of the intense struggle within to find and achieve greatness.
The entire story, however, is about conflicts including all of the characters and I would be happy to answer any other questions you might have.