The joke works because they're moral opposites. Spidey lives by an absolute no-kill code; Deadpool is a lethal mercenary who solves problems with two katanas and a punchline. Peter plays reluctant babysitter, Wade plays overeager stalker-fan, and somewhere between the body count and the guilt trips they become the funniest odd couple in the Spider-Verse.
Deadpool (Wade Wilson) debuted in New Mutants #98 (1991) as an X-adjacent mercenary, with no early connection to Spider-Man. Their first memorable on-page encounter is the fan-favorite Deadpool (vol. 3) #11 (1997, "With Great Power Comes Great Coincidence") by Joe Kelly and Pete Woods, in which Deadpool and Blind Al are thrown back in time and dropped into the recreated events of the classic Amazing Spider-Man #47 (1967) — Wade literally inserts himself into Peter Parker's past, aping and interacting with a young Spidey. Their modern, in-continuity rivalry-turned-rapport was cemented years later in Amazing Spider-Man #611 (2010) by Dan Slott and Marcos Martin, a full-issue clash-and-banter in which Deadpool is hired to hunt Spider-Man, and then formalized as a genuine (very one-sided) friendship in the Spider-Man/Deadpool ongoing series (2016-2019), where Wade decides Spidey is his best friend whether Peter likes it or not.
After the 50-issue Spider-Man/Deadpool ongoing wrapped in 2019, the two remain established frenemies: Deadpool loudly considers Spider-Man his best friend and moral role model, while Peter tolerates him with wary exasperation, never fully trusting Wade's methods. Since then their arcs have largely run in parallel — Deadpool through his own solo runs and team-up specials, Spider-Man through his ongoing titles — with recurring guest spots and event crossovers keeping the rapport alive rather than any single shared series. The relationship stays affectionate but unequal, and Deadpool's growing (if erratic) heroic reputation keeps him in Spider-Man's orbit as an occasional, chaotic ally.
Wade Wilson is a wisecracking mercenary carrying an accelerated regenerative healing factor that makes him nearly impossible to kill — sever it, burn it, blow it up, and the man just stitches himself back together and keeps talking. On top of that he's a master assassin, martial artist, and marksman, lethal with swords and firearms alike.
His signature trick isn't a power at all: Deadpool breaks the fourth wall. He knows he's a character in a comic, reads his own captions, and cheerfully argues with the narration. Unkillable, unfiltered, and fully aware he's fictional — that self-aware chaos is the whole character.