Humor is heavily based on aggression and may have evolved in part through sexual selection pressures. In many species, including humans, humor and wit can be a way for individuals (particularly males) to demonstrate their intelligence, creativity, and social dominance to potential mates.
By making others laugh, an individual can showcase their mental agility and ability to think on their feet, which may be attractive qualities in a mate. Additionally, humor can be used to put down rivals or assert oneself in a social hierarchy, which can also be advantageous from an evolutionary perspective.
So while humor and laughter can serve to build empathy and social bonds, they may also have emerged as ways to navigate complex social dynamics and establish dominance in a group.