Loyalty is an important theme in Beowulf, perhaps one of the most important themes. In particular, we see the idea of loyalty touched on primarily in the loyalty of warriors to their lord.
Warriors' loyalty for their lord was an important structural element for the society in Beowulf. Warriors were expected to provide services for their lord (often by fighting for him on the battlefield), and the lord was expected to pay back this loyalty by providing his warriors with gifts, such as rings, armor, weapons, etc. We see this relationship at work several times in the poem. First, we see Beowulf fighting for Hrothgar on successive occasions (first against Grendel, and then against Grendel's mother), and Hrothgar responds by rewarding him lavishly. Though Hrothgar is not actually Beowulf's lord, Beowulf still feels very loyal to him. It is this relationship of loyalty that ultimately keeps Heorot safe and keeps the forces of chaos in the wilderness where they belong. Likewise, when Wiglaf shows loyalty by aiding Beowulf in his fight against the dragon, Beowulf rewards the young warrior with a collar of gold to show his gratitude.
Conversely, we also occasionally see the ramifications of the lack of loyalty. When it is clear that Beowulf is in trouble in his battle facing the dragon, most of his warriors flee and fail to protect their king. Only Wiglaf comes to Beowulf's aid and, though the two warriors defeat the dragon, the battle ends with Beowulf's death. It could easily be argued that Beowulf dies because his warriors do not live up to their own code of loyalty. Thus, the suggestion is that, if one breaks the code of loyalty, the foundations of society and government (represented here by the king) are in grave danger. This example shows us just how important loyalty was for the society in Beowulf.
Loyalty is an honored trait in the story of Beowulf as in many medieval tales. The idea of chivalry, that code of proper behavior that is associated with medieval knights, centers around loyalty - loyalty to a leader, to friends, and to love. In Beowulf, we see loyalty to leaders many times. When hearing of the attacks by Grendel, Beowulf rushes to the aid of Hrothgar, a friend of his father's. It is loyalty to the father that gives Beowulf the cause to be there. Beowulf brings his bravest soldiers with him, and those soldiers go because they are loyal to Beowulf - even though the stories of Grendel's attacks are terrifying. They sleep in the castle with Beowulf despite the fact that Grendel's attacks have sent other soldiers away. Beowulf is their leader and they will do what he asks.
When Grendel is killed, his mother vows vengeance on Beowulf. Her desire for revenge comes from love and loyalty to her son.
Later in Beowulf's life, he vows to protect his village from the attack of the dragon. Although much older, he goes off alone, believing it is his duty. This is his loyalty to his own people. He could send others to fight the dragon, but instead he takes it upon himself. Wiglaf goes with him, by his own choice, believing it is his duty to protect his leader and, in doing so, he remains loyal to his leader.