"Chance" appears in line 7 in the following context:
Under the bludgeonings of chance
My head is bloody, but unbowed.
Chance in this case emphasizes that the harsh fate the speaker is suffering is not fated or preordained but merely what has happened to him randomly. He is rejecting the idea that he is a tragic character with a tragic fate. The line saying that he is "bloody, but unbowed" emphasizes that he is not giving in to his unfortunate current circumstances.
This ties in with the theme of the poem that a person is a master of their own destiny. The speaker may be in a "pit," but he calls his soul "unconquerable." He is defiant as he faces down death and declares that he is "unafraid" of death—or of pain, or aging, both of which are encompassed in the "menace of the years."
He ends the poem with the stirring words that he is
the master of my fate,
I am the captain of my soul.
This kind of stiff-upper-lip theme is typical of late Victorian poetry, in which people, men especially, are encouraged to remain undaunted in the face of any pain or danger, repressing their fears so they can face the world boldly.
This reflects a Victorian optimist: that the world can be mastered and controlled by exercising inner strength and developing a courageous character, ideas that would be challenged in the coming century.