In the new season of “Curb Your Enthusiasm,” Ted Danson, one of Larry David’s frenemies on the show, is separated from his wife, Mary Steenburgen, and begins dating Larry’s ex-wife, Cheryl. By the third episode, Cheryl and Ted have been to Hawaii together, she is calling him by the cutesy nickname T, and the two gaze upon Larry with the smiling pity of the newly smitten. “Strangest man on the planet,” Ted murmurs to Cheryl about her ex, in the season première. Whereas Larry and Cheryl were soul mates of a sort, both seeing the world through an amused, ironic lens, they never looked like a natural pair; Cheryl is beautiful and cheerful, Larry is a rumpled misanthrope. Cheryl and Ted, meanwhile, look like a perfect match—vigorous and tan and living their best L.A. lives. Larry, as ever, takes none of this well. In retaliation, he proposes to Ted that he’ll ask Mary on a date, to Ted’s amusement. “Oh, Larry David is not cool enough for Mary Steenburgen, but Ted Danson is?” Larry asks. Ted responds, “I didn’t say that, but there’s something in there . . .” Mary, of course, turns Larry down.

This isn’t the first time that Ted Danson has gotten under Larry David’s skin, or that David has found himself compared unfavorably to the television icon. In 1992, the fourth season of “Seinfeld” included the famous show-within-a-show arc in which Jerry and George pitch a sitcom about “nothing” to NBC, a narrative that loosely tracked the real-life experience of the show’s co-creators, Jerry Seinfeld and Larry David. At one point during the pilot negotiations with the network, George, convinced that he and Jerry are getting lowballed, lashes out. “It’s insulting. Ted Danson makes eight hundred thousand dollars an episode,” he shouts. “I can’t live knowing that Ted Danson makes that much more than me.” George complains that he’s just as good as Danson; Jerry reminds him that he is, in fact, “much, much worse.”

It was a good insidery joke, if a bit exaggerated. A year earlier, Danson, as part of his own contract negotiations with NBC, had reportedly demanded half a million dollars an episode to continue playing Sam Malone on “Cheers,” which was the highest-rated comedy on television (and, in 1992, aired on Thursdays, the big draw right before “Seinfeld”). The joke was made funnier by the obvious discrepancy between David’s fictional stand-in, George—slovenly, pathetic, and anonymous—and Danson, who was handsome, charming, and, at that time, the biggest TV star in the country. Yet there was a kernel of credibility to George’s outrage: Danson played the relief pitcher turned bartender Sam Malone with a kind of effortless-looking panache that could make him seem like little more than a handsome lightweight. Maybe he wasn’t that special after all.

George, as he was in all but one famous episode, was entirely wrong. If “Cheers” was arguably the perfect sitcom, then Sam was the perfect leading man. He was a bright star around which the show’s beloved weirdos orbited, with him beaming at the center of it all. He looked less like a former ballplayer than he did a dancer, prowling behind the bar, a towel thrown jauntily over his shoulder in between polishing glasses. In a way, he was a familiar TV lothario, an inveterate ladies’ man—tall, stylish, with a coiffed mane, tight pants, a few buttons on his shirt undone, his eyes always searching for a mirror. But though he played at being a “mimbo,” to borrow a “Seinfeld”-ism, he was smarter than he let on. And there was something vulnerable about him, too, a compelling undercurrent to his machismo that gave the show its sense of realism and pathos. Sam was charming, rakish, alluring, but, though he slept with scores of women, he never got the girl. The women on the show—Diane, Rebecca, Carla, even Lilith—each of whom he loved, in different ways, ran him in circles and left him dizzy, amused, thrilled, and happily beaten. He adored his patrons, and his bar, and transmitted that love to the audience. The show’s perfect final scene, in a 1993 finale that drew a reported ninety-three million people, finds him closing up for the night, alone.

After “Cheers,” Danson wasn’t finished annoying Larry David. By 1998, when David returned to “Seinfeld” to write that series’ finale (with a mere seventy-six million viewers), Danson was still on his mind. In the episode, George and Jerry, once again offered a TV show on NBC, are being flown out with Elaine and Kramer to meet with the studio people in Los Angeles. “You think this is the plane that Ted Danson gets?” George asks, disgusted at the poor quality of the private jet. “Ted Danson is not even on the network anymore,” Jerry reminds him. “Still, I bet when they gave him a plane, it was a lot nicer than this one,” George says. He was right to worry: the plane eventually malfunctions, leading to an emergency landing and the shenanigans that eventually land the quartet in prison.

Two years later, the meta-feud continued, as Danson and Steenburgen appeared in the second episode of the first season of “Curb Your Enthusiasm,” playing gently self-mocking versions of themselves on a bowling date with Larry and Cheryl. Larry, no longer hiding behind his onscreen alter ego George Costanza, is put off by Ted’s pervasive sunniness—Danson proclaims everything major or minor to be “heaven”—and complains to Cheryl, “I could kind of take him or leave him.” In the third season of “Curb,” Danson reappears, his hair gone white, for an extended story line in which he and Larry invest in a restaurant together, and quickly settles into the role that he continues to play—competitor, foil, agitator of Larry. Over the seasons, they’ve squabbled over shirts, birthday gifts, naming rights to sandwiches, and the length of Larry’s running shorts.

In their exchanges, Ted comes off, at least when compared to Larry, as the calm, reasonable one, the cheerful and lovable goy—which only makes Larry angrier. Yet that distinction is merely relative; one of the strengths of Danson’s performance on “Curb” is the way he subverts his nice-guy persona, layering in pettiness and malice. Of course, only Larry can see it; to the rest of the world, Ted is just the nicest guy. Take, for example, Danson’s best moment on the show: the episode, in Season 6, in which Ted anonymously donates money for a new wing of the Natural Resources Defense Council building, making Larry’s own named donation seem vainglorious in comparison. Worse, Ted manages to have it both ways, telling people in private that he is the modest anonymous donor. Everyone—including Cheryl, and even Senator Barbara Boxer, in a cameo—is moved by Ted’s modest generosity, and he laps up the praise like a man accustomed to being admired. Larry, meanwhile, fumes, “It’s faux anonymity!”

The zany verisimilitude of “Curb” is such that it’s sometimes easy to forget that David and his friends aren’t reënacting scenes from their real lives. When I saw that Ted would be pursuing Cheryl this season, I quickly Googled it and was relieved to see that Danson and Steenburgen remain, by all appearances, one of Hollywood’s most gushingly in love married couples. Similarly, it should be noted that there is no real animus between David and Danson. In a recent interview, Danson told the journalist James Andrew Miller, “Larry David kind of changed my career for the better.” After “Cheers,” Danson briefly tried and failed to be a movie star, and then settled into a long run as the star of the medical comedy “Becker.” By 2000, he seemed fated to remain, in the minds of most viewers, the guy from “Cheers”—the gilded cage inhabited by a certain kind of television royalty, watching the prestige of the medium rise up around him without carrying him along. But then he started turning up on “Curb,” showing viewers that the mixture of self-assuredness and insecurity, of obliviousness and deep empathy, that they’d loved about him as Sam had aged into something still richer. By playing an exaggerated version of himself, he reignited a second act in which he could be whomever he wanted to be.

As with Julia Louis-Dreyfus, and only a handful of other actors, it is now nearly impossible to imagine modern television without Danson. In the past fifteen years, he’s fleshed out aspects of his “Curb” character in greater detail in a wide assortment of critically acclaimed and popular shows. There was the giddiness and joie de vivre of the magazine editor on “Bored to Death,” the rapaciousness of the brutal tycoon on “Damages,” the generous wisdom of the local sheriff in “Fargo,” and the simple reliable Ted Danson-ness of his turn helming the stalwart CBS procedural “C.S.I.” through its final years. His return to the new season of “Curb” coincides with his scene-stealing performance in the NBC comedy “The Good Place,” in which he seemed to be playing an architect of happiness in Heaven before, in a remarkable twist at the end of the first season, sold entirely by a single evil laugh from Danson, he outed himself as an agent of the Devil. Anyone who’d watched Danson go from grandly offering Larry a piece of pie to calling him “a fucking sissy” on “Curb” was prepared for the transformation.