“...without intelligence, there can be no humour.” -Don Quixote
Part I of Don Quixote is hilarious in a way I didn't think a 400-year-old book could be. Everything about the humor feels almost modern. The story is ironic and self-aware. It lampoons the tropes of chivalry stories then gives a big ol' wink to the reader that wouldn't have been out of place in an episode of The Office.
The Simpsons and South Park are Don Quixote's spiritual children--fart jokes and social commentary are given equal weight. If you're writing a comedic story, the structure of Don Quixote would be a great place to start.
Jokes...and social commentary
Don Quixote is also THE prime example of how to create a protagonist/sidekick relationship. Sidekicks or secondary protagonists are often written as some rather...unsavory tropes. You don't want to write a sassy black woman or a magical negro or a gay best friend. Trust me, you don't. Please step away from the stereotypes.
As-is, these tropes are tired and create one-dimensional characters that do not add anything to your narrative. They should be subverted at all costs.
The best way to do this is...to actually create a well-rounded character. Even if this character isn't dynamic (they don't have their own narrative arc) they can still be well-rounded.
Sancho Panza is one of the best examples. As a paunchy peasant with an eye towards money, he acts as the perfect foil to the rail-thin and delusional Don Quixote.
All he wants is to become rich and govern his own insula (even though he doesn't know what an insula is.) He isn't book-smart, but he supplies practical wisdom to the story. He tempers Don Quixote's madness by acting as the reader-surrogate, asking all the necessary questions and undermining some of Don Quixote's more extreme behaviors. At several points in the story you have to admire his ingenuity.
He has strengths and flaws . We know things about him. He has a wife and marriage-age daughter. He is talkative and sometimes acts cowardly. He grumbles to himself when he is angry. Most importantly, he has his own desires. If you create a sidekick character whose sole motivation is the happiness and well-being of the protagonist, that character needs work. Especially if they are in multiple scenes.