Stephen Sondheim can’t fail. The Broadway icon, who turns ninety this Sunday, has won eight Tony Awards, snagged a Pulitzer Prize, and contributed more to American theater than any other living composer.

Even Sondheim’s flops manage to succeed. Take Merrily We Roll Along. The 1981 musical was panned by critics and led to the dissolution of Sondheim’s longtime partnership with the producer and director Hal Prince. Itcollapsed after sixteen infamous performances at the Alvin Theatre. For someone of Sondheim’s caliber, it doesn’t get much worse than that.

But in the forty years since, the show has had quite a second act. Paradoxically, its failure was a success of sorts. In misfiring, Sondheim and Prince managed to transform Broadway in more ways than one.

Based on a 1934 Kaufman and Hart play of the same name, Merrily tells the story of three friends trying to make it in New York. The show begins in 1976 with the characters unhappy and estranged, and then proceeds backwards to 1957, when they were young and idealistic. A handful of musical themes run through the show, including reprises of the titular opening number to mark transitions back in time.

Audiences bristled at the show’s weighty subject matter and found the structure confusing. Critics panned the show, including The New York Times’sFrank Rich, who called it “a shambles” and said he watched the show “with an ever-mounting—and finally upsetting—sense of regret.”

After Merrily closed, Sondheim and Prince—who had partnered on eight musicals, including West Side Story and Sweeney Todd—would not work together again for two decades. But the destruction of the Sondheim–Prince partnership was fruitful, propelling both men into new and incredibly consequential phases of their careers.

Sondheim responded to the critical rejection of Merrily by going off-Broadway. His next show, written with the playwright James Lapine, was Sunday in the Park with George, an ambitious tale of love and art inspired by Georges Seurat’s A Sunday Afternoon on the Island of La Grande Jatte. When writing Sunday, Sondheim says he “worried less about punctuating the piece with applause and concentrated more on the flow of the story itself.”

Sondheim and Lapine would go on to collaborate on Into the Woods and Passion. Together, this trio of shows redefined the Broadway musical and ushered in a more experimental and artistic era of musical theater.

Prince took a more commercial turn. As Broadway was finding its groove in the 1980s with a string of high-profile hits, Prince made his own mark, collaborating with Andrew Lloyd Webber on The Phantom of The Opera,a commercial success the likes of which had never been seen. Now the longest running show on the Great White Way, Phantom has grossed over $6 billion worldwide.

The critic Michael Riedel notes that tourists “braved the still sketchy” Times Square to see Phantom and other blockbuster musicals, even though they were frequently harassed by pickpockets and prostitutes. Seeing an opportunity to attract even more business, New York theater owners emerged as the driving force for the revitalization of the theater district. Gerald Schoenfeld, the chairman of The Shubert Organization, was an early proponent of the “broken windows” theory largely credited with reducing crime in the city.

Eventually, the theater community’s efforts to clean up Times Square paid off. In 1995, Disney signed a forty-nine-year lease on the New Amsterdam Theatre, which soon became home to shows like The Lion King and Aladdin. Buoyed by big-name musicals with wide appeal, Broadway attendance rose from 7 million to 11 million between 1990 and 1998. Last season, 15 million people came to Broadway shows.

While Sunday in the Park brought high art to Broadway, Phantom brought Broadway to the masses. By setting a new bar for success in musical theater, it changed Broadway and New York City itself. Over time, meanwhile, the American theater has come around to Merrily.

One of Sondheim’s most frequently revived musicals, Merrily has seen its time-bending elements featured in popular contemporary productions. A story about depression, alcoholism, and aging may have alienated audiences in 1981, but it has also inspired Tony Award–winning shows like Next to Normal, Fun Home,and Dear Evan Hansen. Each Broadway season, one can expect to see Merrily’sinfluence in theaters up and down Forty-second Street.

Although the Sondheim–Prince split separated two titans of musical theater, it also set the future course of the Broadway musical. Sondheim elevated the form and made way for a new generation of groundbreaking musicals, while Prince cultivated an audience for them. In many ways, the state of Broadway today is the greatest Sondheim–Prince collaboration of all.