In chapter 9 of the Beowulf epic (line 582), Beowulf dismisses Unferth as someone who only talks but but doesn't participate in heroic deeds. But later in chapter 22 (line 1488), Beowulf makes a last will in case he dies in the fight, and in this, he has Unferth inherit his sword. Why did Beowulf suddenly change his view?
Because Unferth changed his mind first.
First, he stopped his boasting when Beowulf had slain Grendel (line 980). And, just before passage you quote (line 1455 and forward), Unferth had lent Beowulf his named sword, Hrunting, further conceding that Beowulf was the greater man.
The logic here seems very straightforward: Unferth borrows Beowulf a sword to use in a combat from which it is not certain he will return. If the worst should come to happen, Beowulf does not want Unferth to have suffered because of him, so he offers his own sword as collateral.
Note that Beowulf's initial view of Unferth is correct, but that it is true also for the rest of the court, and for most of the other characters; apart from Beowulf, Wiglaf is the only character in the poem whose courage does not desert him. It is not Unferth's lack of courage that is the main issue, but rather his boasting - and that had stopped.