His role is essential, and for audiences, almost central. It is also multi-faceted. Most simply, he is an example of a common comic character type from the period, and so he is meant to be funny.
However, to young Prince Hal, he is a substitute father figure, and one who offers acceptance without the heavy hand of expectations his real father raised.
Falstaff is also a kind of worldly education; through him Hal learns about common people, and about the darknesses and complexities of the human spirit. In this odd way, Falstaff allows Hal to become a great king.