"It's Always Sunny in Philadelphia" is in the midst of its 10th season, making it one of the longest-running live-action comedy shows in television history.

But the show's success may not have happened if not for a strange bit of luck brought upon by its network, FX.

Rob McElhenney, Glenn Howerton, and Charlie Day are the creators, writers, actors, and producers of the show, but they weren't big enough names to draw in audiences when they were starting out in 2006.

McElhenney and Howerton recently joined The Nerdist podcast and explained that after a first season with low ratings, FX gave them an ultimatum: Add a star name to bring in audiences or the show is over.

McElhenney recalled the conversation:

So, John Landgraf, who's the president of FX, he called me in for a meeting and was like, 'Hey, no one's watching the show, but we love it, we wanna keep it on, but we don't have any money for marketing, and we need to add somebody with some panache that we can hopefully parlay into some public relations story, just so we can get people talking.'

On the podcast, McElhenney went on to say he, Howerton, and Day were hesitant to add a big name and change the way they were writing and making the show. He says FX threw around some names, including Danny DeVito.

Glenn Howerton says DeVito was perfect for the role because he had played so many "despicable characters" but had a warmth underneath that seemed to fit the show's tone. Alberto E. Rodriguez/Getty Images

"It's not that we were reticent to the idea of adding Danny to the show," Howerton recalled, "it's that we were reticent to add a name to the show. You know, because we kinda liked that we were no-names and it was this weird, small thing, you know."

McElhenney says they told FX: "No, I just don't think we wanna do that, and they were like, 'Oh OK, well, you know ... the show's over.'"

McElhenney, Howerton, and Day then opened up to the idea and talked to DeVito, who apparently already knew about the show because his kids watched it.

Howerton says DeVito was perfect for the role because he had played so many "despicable characters" but had a warmth underneath that seemed to fit the show's tone.

DeVito joined the show for the second season, playing Frank Reynolds, the legal father of twins Dennis and Sweet Dee.

In 2014, Entertainment Weekly ranked "It's Always Sunny" No. 7 on its list of the "26 Best Cult TV Shows Ever," noting, "It's a great underdog story ... If it sounds too dark for you, consider that there's an episode about making mittens for kittens, and it's adorable."

