Though primarily a comic figure, Falstaff embodies a depth common to Shakespeare’s major characters. A fat, vain, and boastful knight, he spends most of his time drinking at the Boar’s Head Inn with petty criminals, living on stolen or borrowed money. Falstaff leads the apparently wayward Prince Hal into trouble, and is ultimately repudiated after Hal becomes king.
That, however, is not Falstaff’s only role.
He is also a foil in Shakespeare’s sarcastic commentary about general corruption (Henry IV Part 2). That is not directly related to his relationship with Prince Hal. The point of that bit is how the system lets Falstaff get away with his shenanigans. Like recruiting Mouldy, Shadow, Wart, Feeble and Bullcalf, and getting paid to do so.
Shakespeare loved Falstaff. He is the only character he used in three plays.