The protagonist, Beowulf, in the anonymous, Beowulf, travels to a distant land to fight a threatening monster in order to achieve fame and glory.
Like the ancient Greeks of myth, Beowulf hopes to gain immortality through fame. His passion is to be remembered after he dies, and the way to accomplish this is by performing great, heroic deeds.
He does say that he's come because it's his duty to help:
My people have said, the wisest, most knowing
And best of them, that my duty was to go to the Danes'
Great king. They have seen my strength for themselves. (244-246)
And that is certainly a part of his reason for coming.
But in general, Beowulf has his legacy in mind. He is so worried about his reputation that he even announces that he will fight Grendel without a sword, since the monster doesn't use a weapon. He wouldn't want anyone to think less of him for using a weapon against a weaponless monster.
In my opinion, Beowulf does this because of his desire to be famous and honored. This was what warriors wanted -- a chance to distinguish themselves in battle and to show that they were the bravest or best warrior around.
Imagine how great of a thing it would be for Beowulf to defeat Grendel. Here is a monster that is so fearsome that it can kill whole groups of warriors all at once. So whoever can defeat it will surely become very famous. Because defeating Grendel would make Beowulf famous, it did not really matter to him who the monster was endangering -- he just wanted to be the one to kill it.