Hrothgar believes that Beowulf is coming to Denmark to help defend his mead hall, Heorot, against Grendel because, years ago, Hrothgar helped Beowulf's father, Edgetho, end a feud with another tribe, the Wulflings. To Hrothgar, who also acknowledges that Beowulf comes out of friendship, this act is, at least in part, the repayment of a debt.
As soon as he hears the news of what is going on, Beowulf gathers his men and sails for Denmark. He may be repaying a debt, but defending civilization against the barbarism represented by Grendel is also simply part of Beowulf's makeup: it is integral to his code of honor. He doesn't run and hide or fear the monstrous but has the courage and strength to confront and defeat evil. In doing so, he lives his life in such a way that he will leave a lasting legacy.