Answer:
it provides comic relief
Step-by-step explanation:
Hamlet spends a great deal of the interaction bothered with Osric's hat and talks to Horatio about how he is important for being the owner of a lot of dirt.
"HAMLET : (speaking so that only HORATIO can hear) You’re lucky, since knowing him is most unpleasant. He owns a lot of good land. Give an animal a lot of money, and he’ll be welcome at the king’s table. He’s a j*rk, but he owns a whole lot of dirt, so he’s treated well."
Horatio also implies that Osric is not very smart.
"HORATIO : (speaking so that only HAMLET can hear) All his fancy language has run out finally; his pockets are empty."