Note: This story touches on plot points from episodes leading up to the series finale of “The Good Place.”

Several years ago, Michael Schur went to a Starbucks and pondered the human condition. He had purchased a cheap coffee and waited until the barista turned toward him to toss his change into the tip jar, realizing immediately how silly it was that he wanted recognition for such a small act. Stuck in traffic later on, he mulled over his “corrupt and bad” motivations — only to have his thoughts interrupted by another driver pulling into the breakdown lane to speed past everyone else.

“Well, if someone is keeping track,” Schur, in an interview with The Washington Post, recalls thinking, “that guy just lost 25 points.”

Hold on. If someone was keeping track of it all — not in the manner an organized religion would, but in a “purely mathematical, moneyball way” — would he, Mike Schur, have gained or lost points earlier for doing a good thing for a bad reason? How many points would he gain for a purely good deed?

Thus, “The Good Place” was born.

The NBC series, the showrunner’s first solo outing for the network but his fourth sitcom overall, airs its finale Thursday, capping a four-season exploration of what it means to be a good person. It’s the rare show in this doom-and-gloom era to consistently find humor in its rendering of the afterlife. Viewers laugh at Eleanor Shellstrop, Kristen Bell’s character who realizes a points-based system has “mistakenly” landed her in a heaven-like utopia. They might also share her desire to make up for countless moral imperfections by learning to be a more ethical person.

“When I threw that 27 cents into the Starbucks jar, my reaction was purely and simply to laugh at myself,” Schur says, “It was like, ‘You idiot. What are you doing, you goofball? I can’t believe how dumb it is that you care that the barista sees you tip 27 cents.’ ”

“I think people don’t like being lectured to — I don’t like being lectured to, frankly. If moral philosophy wasn’t just going to be a tertiary part of the show but instead was going to be baked into the very center of it, then comedy was a much better delivery mechanism.”

As “Parks and Recreation” neared its end, NBC asked Schur if he’d consider writing a family sitcom next. Schur, who created “Parks and Rec” with Greg Daniels, his boss on “The Office,” had become one of the network’s most prolific creatives by working within what he calls “very low-fi” settings: a paper company, a local government office, a police department (in “Brooklyn Nine-Nine,” which he also co-created).

After considering the pitch, Schur realized he had nothing new to say: “I’m a white, middle-class kid from Connecticut, and I have a white, upper-class family in Los Angeles,” he explains. “The Caucasian American family is the most well-covered subject in the history of television, by far."

“The Good Place” ditches the family unit in favor of focusing on the motivations of individual people: Why does Eleanor have such a hard time being sincere? Why doesn’t ethics professor Chidi Anagonye (William Jackson Harper) ever know what he wants? What is socialite Tahani Al-Jamil (Jameela Jamil) hiding behind her glamorous exterior? And why does Jason Mendoza (Manny Jacinto), an amateur DJ, say the things he does? Combine those dead folks with Michael (Ted Danson), a Bad Place demon who fools the others into thinking they’re in the Good Place — the first season finale’s big reveal — and Janet (D’Arcy Carden), basically a walking database, and you’ve got a diverse set of personas to play with.

The show marked Schur’s first time working with such an abstract premise, so he looked to another writer for guidance: Damon Lindelof, the man behind “Lost” and “The Leftovers,” a pair of TV dramas dealing heavily with death and the afterlife, as well as the critically acclaimed “Watchmen” series.

Lindelof’s advice was invaluable: You have to know where you’re going with a premise like this, or you’ll start to run in place, and the audience will sense it. The “Good Place” writers’ room planned a full year ahead; each time they began working on a season, they already knew how it would end.

“The Good Place” is heavy on plot, whether regarding the intricacies of the points system or emotionally fraught story lines like Eleanor continuing to spearhead the group’s plan to save humanity after it requires them to clear the memories of Chidi, her love interest. But underlying it all is the basic question of how to judge certain patterns of behavior. The ensuing conversation is remarkably void of religion, with perhaps the exception of Jason masquerading as a silent Buddhist monk early on.

The philosophical approach was Schur’s intention from the start.

“Every world religion is trying to make sense of a world where humans are just milling around, bumping into each other and doing different things,” he says. “I’m more interested in the milling around, not the overall concept of how a human-made system would judge those actions in relation to what happens to you after you die. … We’re only here for a short amount of time, and we only have a certain number of actions we partake in. I’m trying to get to the bottom of what makes those actions good or bad.”

Everyone wants to know what it’s like to work with Ted Danson, and Schur has the answer: “Ted is a monster. He’s a terrible person. He’s rude and callous. He’s not thoughtful or kind. I’d say he’s a cruel, cruel person, sadistic, unfeeling, not talented, not funny, not a good actor. Just one of the biggest mistakes of my professional life was casting Ted Danson.”

He’s kidding, of course. Plus, once you cast Danson and Bell in a series, Schur adds, the network lets you cast pretty much anyone else you want. He went with four actors whose profiles have risen a great deal since they first wandered into the Good Place: Jacinto, whom Schur describes as “the most likable human being I’ve ever met”; Jamil, who had never acted before but delivers performances Schur likens to “sitting down at a concert piano onstage at the Lincoln Center and playing an entire sonata from beginning to end”; Carden, whom he credits with shaping Janet’s transformation from a one-dimensional to a full-bodied character; and Harper, who might have had “the hardest job of anybody.”

“He’s the voice of reason … and it’s incredibly hard to make that funny,” Schur says. “Unless you’re Will Harper, in which case it seems to be easy.”

Each time they turned a string of silly scenarios into a cohesive episode, the writers made sure they checked off six boxes. To ensure character development, viewers had to learn a new thing about at least one character — something Schur picked up from his time on “The Office.” (“I didn’t know Oscar liked jazz, or whatever,” he explains.) Each episode had to ask and answer a question about ethics. It had to be compelling, consistent with the long game and take advantage of the realm’s magical properties.

Finally, as a part of NBC’s comedy block, it had to make viewers laugh.

“The Good Place” doesn’t shy away from dense material — Schur enlisted moral philosophers to consult on the show, which spent a full episode on the famous trolley problem in its second season — instead using humor to make it palatable. Eleanor cracks jokes whenever Chidi launches into deep philosophical explanations, mirroring Schur’s frustration with the philosophy books he was reading. The idea, he says, was to simply to take these ideas and “throw them up in the air, bat them around and have the characters do what humans have done traditionally, which is try them on for size and see if they fit."

It’s difficult to strike the right balance between humor and complexity, Schur adds, and they did a lot of experimenting in the show’s early days. If someone writing about the afterlife were to approach him for advice, as he did Lindelof, Schur says he would underscore the importance of tone.

“When you set a show in a realm where anything is possible, the temptation is to do anything, to go ‘Looney Tunes’ and let your imagination run wild,” he says. Mayhem can be good in small doses. But too much of it, and you end up in the Bad Place.

Read more: