First, the procedure in the scene is modelled (as indeed much of what follows)
on the scene in Beowulf when Beowulf and his men arrive in Denmark and
are immediately challenged by the coast-guard with the words:
"Who are ye armed men, protected by mail, whom this lofty keel has come
bringing over the sea-way, hither across the waves? I for a time have
been the coast-guard, have kept the sea-watch, that on the land of the Danes no
enemy might do injury with a ship-army. By no means do shield-bearing men
undertake to come here openly. Nor do ye the leave-word of warriors,
kinsman's consent, for certain know... Now I wish your ancestry to know,
before ye, far from here, false spies, travel any farther in the Danes'
land. Now ye foreigners, sea-crossers, listen to my plain thought: Haste
is best to make known whence your comings are." (Ll. 237-257).
Only after Beowulf has impressed the coast-guard and convinced him that he,
Beowulf, is no spy, but an honourable man, only then is permission to proceed
granted him. In what follows, step for step, every action which Gandalf
and his companions take, is modelled on the corresponding scene in
Beowulf (the next challenge at the entrance to Meduseld is paralleled by
a similar challenge at the entrance to Heorot; and the demand to disarm before
entering the mead-hall).
Second, why does Gandalf speak boldly to the guard? For the same reason
that Aragorn doesn't flinch before Éomer's spear: By answering boldly Gandalf
impresses the guard, earns his respect; the same way Aragorn earned
Éomer's. With the fearless be fearless. If Gandalf had not answered
the challenge boldly, the guard might not have consented to depart from
standing orders to admit no strangers. Because Gandalf stands up to him,
the guard assumes that Gandalf is courageous and worth giving a second thought
to -- a second thought which leads to an enquiry, if Gandalf and company might
not be admitted to Edoras after
all.
__________________________________
All that is gold does not glitter,
Not all those who wander are lost;
The old that is strong does not wither,
Deep roots are not reached by the frost.
From the ashes a fire shall be woken,
A light from the shadows shall spring;
Renewed shall be blade that was broken,
The crownless again shall be king.