Rob Delaney’s first claim to fame was his Twitter feed, which Vulture once described as “a steady stream of jokes so demented and filthy as to be unprintable here and almost everywhere else.” He is best known for his television series “Catastrophe,” a messy, humane, and hilarious show about marriage that he co-wrote and co-starred in with Sharon Horgan. “Catastrophe” aired its final episode in February; Delaney’s upcoming projects include an Amazon standup special called “Jackie” and a role as Megyn Kelly’s producer in the film “Bombshell,” coming in December, about the disgraced Fox News C.E.O. Roger Ailes. Delaney has also spoken in moving detail about getting sober in his twenties and of his two-and-a-half-year-old son, Henry, who died of a brain tumor in January of 2018. He spoke with Emily Nussbaum, the television critic for The New Yorker, about his beginnings in musical theatre, the cinematic influences on “Catastrophe,” writing while grieving, and why he wants to “smash” and “destroy” private health insurance in the United States.

This interview has been edited and condensed.

I read your memoir, which is a wonderful mixture of funny and sad, and I realized a lot of things I didn’t know about you. One of them is that you used to be big into musical theatre.

Yeah, I have a bachelor of fine arts from N.Y.U. Tisch School of the Arts’ musical-theatre program. I graduated in ’99. My first job was as Sir Lancelot in a touring production of “Camelot.” That’s what I thought I was going to do. But then I found comedy.

Did you turn against musical theatre? You wrote in your book about wanting to live your life as a musical.

I didn’t turn against it. In 1998, [the writer and comedian] Julie Klausner worked at St. Mark’s Bookshop, which I think is not even there anymore. I didn’t know her, but we started talking because I was buying a book, and she told me, “There’s these guys, the Upright Citizens Brigade, you should see them.” So I did. I saw Amy Poehler and Tina Fey and others, and was, like, Yeah, I’m going to do comedy now.

Did you join one of the classes?

I signed up, but I could never take them, because of various—I’d get another job, or I would be drunk. But I did ultimately take [classes] at ImprovOlympic in Los Angeles.

Tell me a little bit about that switch into comedy. You did your first open-mike night a year after you got sober.

I was doing a national tour of “Camelot,” and our bus broke down. We were going to be late getting to our theatre that we were performing at in West Virginia that night. We had to do sound check at every new theatre, so Arthur would do sound check, then Guinevere, then me. We would always do lines of dialogue and a few bars of a song. But we got there later than the audience did, because of our bus breakdown, so there were twenty-five hundred people in the theatre. Arthur gets up and does some lines of dialogue, then Guinevere, and then I got up and was, like, Wait, these people are about to see us do the play—I don’t want to spoil the legend of Camelot. So I’ll just tell them about our day. I told them about the bus breaking down and people laughed, and, when I heard people laugh in a theatre because of a thing that I thought and said, I was, like, Fuck musicals.

There were twenty-five hundred people there? That’s unusual for a first comedy performance.

I wouldn’t have been funny if I’d known that was coming. I was off-the-cuff, and I was, like, Look at my chill performance style that made everyone so happy. Then, when I specifically went to do standup, the audiences were just, like, “You should kill yourself.”

What were your first standup experiences like? Did you bomb?

Oh, God, yeah. I still do, sometimes. I was bad and not funny. Funny enough here and there that I was, like, I guess I’ll do it again. But it just takes forever to get good.

This was a year after you’d gotten into a major accident in L.A. while blackout drunk and gone through rehab. So you were doing your first comedy sober, and relatively newly sober. Did that affect your comedy?

I don’t think so. I know people who are, like, “Oh, if I get sober, will I still be creative or weird?” For me, the answer is yes. There are lots of things to joke about other than drinking or not drinking. It’s still terrifying whether you drink two beers or not—standup is a ridiculous, stupid thing to do.

In your comedy, you talk a lot about your butt. Why?

You’d think I might not have an answer for that. We all have bodily functions; we’re all embarrassed about them. They’re a great entry point—no pun intended—but they’re a great place to start, because we can all relate. It’s shorthand for any type of emotional shame we might have. Your worst, most embarrassing memory is probably some sort of interpersonal or interfamilial horror, romantic shame, but we can all bust into that faster if we just talk about the time you shit your pants. Then we’re all embarrassed and we can start to do the real work of comedy.

You met Sharon Horgan through Twitter?

I was a fan of her amazing show “Pulling,” and I noticed that she followed me on Twitter. I wrote to her—now ten years ago—and said, “Hey, I love your show, and you, and will you be my friend?” We wound up meeting for coffee and became friendly; we introduced our families to each other and stuff. A few years later, we wrote the pilot of “Catastrophe” together.

One great thing Channel 4 did was: we started the show with [the protagonists Sharon and Rob] already married, and Channel 4 was, like, “What if we see them meet?” And we thought, Surely, that’s like half an episode. Turns out it’s a whole season. Thank you, Channel 4. Sometimes network notes are good.

I was fascinated that you didn’t do any improv on the show—you guys have talked about carefully crafting all the dialogue.

The way we would write is: we would talk, imagine the scenes, transcribe what we were saying, and then read it out loud again, many times, to make sure it really sounded like stuff that would come out of a human mouth, because we were both turned off by shows that sounded too scripted. You’ll hear stuff in some shows, and you think, All right, that’s clever, but it sounds to me like it’s being read off a page. We did work hard to make it all seem realistic and spontaneous, but we didn’t do it through improv.

Also, Sharon and I thought of ourselves as every character in the show, so we wanted to selfishly have all the fun with all the other characters, and then have people come in and just recite what we’d written. Mostly, we wanted to have as much fun as possible writing it, and then we were, like, “Oh, my God, we have to shoot it, too? Oh, O.K.”