In Anglo-Saxon culture, several things are most important: a belief in fate ("wyrd"--the old English word for fate which eventually becomes "weird" as in the Weird Sisters of Macbeth), loyalty to kinsmen, loyalty pledged to kings/lords, and fame.
Wiglaf comes to Beowulf's aid for all of these reasons. He is related by blood to Beowulf, he has pledged his loyalty as a warrior to Beowulf, and he wants to be famous so he can live forever in the songs and stories told by the bards long after he is dead. Although they are greatly outnumbered by the skill and danger factor of the dragon, the two of them fight bravely while the other warriors simper in cowardice and watch from the safety of the woods.
After the battle, Beowulf names Wiglaf his heir and gives him two commands knowing Beowulf is on his deathbed: 1) claim the dragon's treasure as payment for winning the battle and give it to his people 2) build a grand tower so that all who see it will forever remember Beowulf (the fame thing again).
Wiglaf also harshly reprimands those warriors who ran for being without a sense of honor and duty and for going back on their pledges to the king.
Wiglaf is the only man who does not run from the dragon and who comes to Beowulf's aid. He does so because he remembers and is grateful for Beowulf's generosity in giving him a landholding. He also realizes that, although he is still a great warrior, Beowulf is getting older and is not able to defeat the dragon by himself.