There is almost always one of these. It’s a character trope that extends beyond a single genre and far beyond the realm of anime and manga.
They can be found anywhere, Usopp from One Piece, Yosuke Hanamura from Persona 4 The Animation, Youhei Sunohara from Clannad or even Tiger from Tiger & Bunny.
Basically this character can be summed up with a single quote.
“I’m cool playing second banana.” Yosuke Hanamura.
99% of the time this character is male and immune to death, betrayal and being in a lead role. They usually just aid the protagonist and because of their uncanny ability to receive minor injury for comic value they also make the protagonist look better in the eyes of the ladies. Which explains why in something like Clannad Tomoya can get six or more different girls but Sunohara is doomed to inevitable loneliness which is confirmed even years later in the after story.
The comic relief guy will also spice up conversation with ladies if it is getting boring by either saying something inappropriate or acting perverted. This will get him punched or injured which makes the hero look m*ore attractive in the eyes of said lady. As dumb as this sound I think it could work in real life, I wish I had a comic relief wingman sometimes.
I think it would be interesting to take the role of this character in a dating sim/ visual novel. You would constantly be competing with a more interesting protagonist for the ladies and losing. All your conversations would get you punched and it’s up to the player to pick the ones that effect your relationships with ladies the least. By the end of the game when all the girls except one like the protagonist instead of you. That okay because a lady actually likes you, so now you get that sense of accomplishment as you won a girl with effort instead of just pointing at some girl in a classroom and yelling “Mine!”
I couldn’t think of any but is there any females which play this role in anime? Surely there must be at least one?