Characters from the animated series "The Simpsons": from left, Maggie, Marge, Lisa, Homer and Bart. (Fox via AP/AP)

Sam Simon, the often-overlooked but instrumental co-creator of “The Simpsons,” which popularized the hapless patriarch Homer (“D’oh!”) and his puckish son, Bart (“Eat my shorts!”), and became a phenomenon in the new genre of irreverent animated sitcoms, died March 8 at his home in Los Angeles. He was 59.

One of his business managers announced the death. Mr. Simon was diagnosed with terminal colon cancer in November 2012. Twice divorced and with no children, he vowed to spend his remaining months giving away his fortune to animal rights and conservation causes. They had become his main interests after his acrimonious departure from “The Simpsons” in 1993.

“The Simpsons” is today the longest­-running scripted prime-time series, having surpassed “Gunsmoke” and “Law and Order.” Mr. Simon’s attorneys had negotiated a deal that netted their client $20 million to $30 million annually from the show’s licensing fees from T-shirts, posters, lunchboxes and other paraphernalia. Mr. Simon, who had worked on the network comedies “Taxi” and “Cheers” in his 20s and was widely regarded as a prodigy of television sitcom writing and producing, essentially retired from show business at 38.

Because he had been gone from “The Simpsons” for so long, Mr. Simon was publicly overshadowed by the two other people who conceptualized the characters for a scripted half-hour show: veteran TV and film producer James L. Brooks and “Life in Hell” cartoonist Matt Groening.

Mr. Simon was regarded as a master of sitcom script structure and punch-line setups and helped shepherd “The Simpsons” through its formative years after it launched on Fox in 1989. Prototypes of the characters appeared in small doses on the Fox sketch comedy program “The Tracey Ullman Show” in the late 1980s.

"Simpsons" co-creator Sam Simon, who’s donating his $100 million fortune to charity, discusses his work with "Save the Children USA" in an interview with the organization. (Save the Children USA)

“You can’t overstate his contribution to ‘The Simpsons,’ ” talk-show host and former “Simpsons” writer and producer Conan O’Brien told the Associated Press in 2013. “No one’s smarter than he is.”

“The Simpsons” married the literate and the profane, the culturally sophisticated and the silliest slapstick. Its farcical physical humor could make children giggle, while absurdist gags — a day-care center called “The Ayn Rand School for Tots” — could bring a smile to the dourest PhD candidate.

“Whatever makes the writing staff laugh, we put in the show,” Mr. Simon once told the Los Angeles Times. “That’s why it’s very smart and very vulgar.”

Credit for every character or joke is hard to pinpoint on a collaborative venture such as “The Simpsons.” According to John Ortved’s book “The Simpsons: An Uncensored, Unauthorized History,” Mr. Simon’s most indelible contribution seems to have been the assembly of the original writing team, many members of which stayed in place for years.

Mr. Simon earned the respect of colleagues for his mordant wit. He also supplied crucial insights into characters for “The Simpsons,” whose central focus became Homer, a fat, dumb and lazy safety inspector at a nuclear power plant.

The Homer from the “Tracey Ullman” skits was a mean-spirited, angry father — a cartoon version of the Fox hit show “Married . . . With Children.” Mr. Simon helped transform Homer into a lovable Everyman dolt with terrible parenting skills.

Homer, said media scholar Robert Thompson, “is one of the greatest TV character creations of all time — an incompetent doofus with great American optimism. The whole world can collapse, but as long as there’s a glimmer of hope that a doughnut is in his future, he’s willing to fight again. There’s a nobility to him.”

Mr. Simon was pivotal in imagining the larger universe the Simpsons live in. Their home is the Middle American setting of Springfield, where the mall features such vendors as the Jerky Hut, the Ear Piercery and the International House of Answering Machines.

“He brought a broader perspective to it,” Wallace Wolodarsky, one of the show’s original writers, told Ortved. “He made it bigger than just the family. What’s such an important part of ‘The Simpsons’ is the world of characters it exists in.”

Above all, Mr. Simon tried to keep the cartoon firmly grounded in the rules of normal sitcom “reality.” Ortved quoted one assistant on the show who said that Groening wanted the matriarch, Marge Simpson, to let down her towering blue beehive and reveal rabbit ears. Mr. Simon torpedoed the idea.

When Mr. Simon thought there had been too many “cheap shots” against the nuclear power industry, he issued a directive: “No more three-eyed fish.”

Although regarded by his supporters as a creative visionary, Mr. Simon could also be a polarizing force backstage. His often dismissive, biting style could send writers streaming out of his office in tears, and he complained bitterly about feeling underpaid and underappreciated for his contributions.

Groening told the New York Times that Mr. Simon was “brilliantly funny and one of the smartest writers I’ve ever worked with, although unpleasant and mentally unbalanced.”

Mr. Simon did not disagree. He told “60 Minutes” that working in television brought out the worst in him. “Any show I’ve ever worked on, it turns me into a monster,” he said. “I go crazy, I hate myself.”

The son of a garment industry executive, Samuel Simon was born June 6, 1955, and raised in Beverly Hills. One of his neighbors was Groucho Marx.

Mr. Simon showed early talent for cartooning but was rejected from an introductory drawing class while attending Stanford University. As he recalled to the alumni magazine, the professor explained, “You’d be taking the space of a student who has talent.”

Mr. Simon, a psychology major, became a cartoonist for the campus newspaper and contributed cartoons to San Francisco newspapers. After graduation in 1977, he was a storyboard artist for a studio that made cartoon shows such as “Fat Albert.”

His breakthrough came in 1981 when he submitted an unsolicited script to “Taxi,” a sitcom starring Danny DeVito and Judd Hirsch about a group of cab company misfits. Mr. Simon was hired as a full-time writer and then script overseer until the series (then on NBC) ended in 1983 amid dwindling ratings.

From there, he wrote for the wildly popular NBC sitcom “Cheers” for its first three seasons. He also wrote the script for the 1991 movie comedy “The Super,” starring Joe Pesci as a slumlord ordered by a judge to live in his own building.

After leaving “The Simpsons,” Mr. Simon periodically worked as a director on “The Drew Carey Show,” executive producer of “The George Carlin Show,” host of the short-lived poker series “Sam’s Game” for Playboy TV and a consultant on the FX comedy “Anger Management.” He also managed the world heavyweight boxing champion Lamon Brewster and appeared often as a guest on Howard Stern’s radio shows.

His marriages to actress Jennifer Tilly and Playboy Playmate Jami Ferrell ended in divorce. Survivors include a sister.

In recent years, Mr. Simon was primarily devoted to philanthropy. His Malibu-based foundation gave to charities such as People for the Ethical Treatment of Animals (which named its Norfolk headquarters in his honor) and the Sea Shepherd Conservation Society, a marine conservation organization. His Malibu estate became a sanctuary for dogs rescued from shelters and trained to serve as companions for the deaf.

“Thanks to Bart Simpson,” he said, “I have a pretty good life.”