‘There’s a war going on out there somewhere.” So goes the catchy opening song from the Broadway show “Natasha, Pierre and the Great Comet of 1812.” The idea is the war is happening far away, and the characters of the show, safe in a swinging Moscow, are untouched by it.

With an unusual set, where some of the audience sits on the stage, and a big name in Josh Groban playing the title role of Pierre, “The Great Comet” was supposed to be Broadway’s next big hit. The quirky musical, based on “70 pages” of Leo Tolstoy’s “War and Peace,” was nominated for 12 Tony Awards in 2016-2017, the most of any show that season.

It was frequently called “the next ‘Hamilton.’ ” They would hand out pierogis (Russian dumplings) at the start of the show and music makers during it. Everyone had a raucous good time.

Yet in a month, the show will be over, a victim of a ridiculous backlash over the race of its lead actor.

With Groban in the role, the show was making over $1 million a week. His replacement, Okieriete “Oak” Onaodowan, was in the original cast of “Hamilton” in the dual role of Hercules Mulligan and James Madison. Onaodowan is a talented actor, but he isn’t a marquee name yet, and when he took over as Pierre, “Great Comet” sales tanked. In an effort to save the show, producers tried to bring in theater vet and film and TV star Mandy Patinkin.

As The Post’s Michael Riedel wrote in July: “Panicked, producers Howard and Janet Kagan reached out to Patinkin, a Tony winner and a star of ‘Homeland.’ His box-office clout is indisputable. But he had to come in fast to punch up the grosses. Onaodowan would have to step aside for three weeks starting Aug. 13 (though he would have been paid the run of his contract, and could have returned in the fall).”

The backlash was swift and focused on the fact that Onaodowan, a black actor, was being replaced by Patinkin, a white one.

Kristolyn Lloyd, of the cast of the Broadway show “Dear Evan Hansen,” tweeted the decision was “bs.” The Web site Broadway Black noted: “It is ironic when Black actors participate in narratives about colonial history, change present day history by adding to the diversity of Broadway, and then are easily replaced as if their only value to a production is based on ticket sales.” Actress Cynthia Erivo tweeted, “Ticket sales shouldn’t override a person doing his job.”

That’s the height of naiveté. The producers of the show had a job to do: keep ticket sales high so the show could go on and everyone involved, from actors to ushers to stagehands, could stay employed. Instead, the show is closing.

Because of the outcry, Patinkin immediately disengaged from the show, saying he “would never accept a role knowing it would harm another actor.” But that’s silly. Obviously, when Patinkin takes any role he is “harming” the other actors who didn’t get the role. Should he have turned down starring roles in shows like “Homeland” and beloved films like “The Princess Bride”?

Yet this was seen as an entirely different situation because of the races of the actors involved. That Onaodowan had taken over for a white actor in the first place was hardly mentioned. That “The Great Comet” was the most diverse show currently running on Broadway was ignored.

One actor couldn’t sustain the show with his name, and another possibly could. That one actor was black and one was white was entirely beside the point.

The left, insistent on seeing everything through the prism of racism, can’t understand what happened. “There’s No Easy Answer for Why ‘The Great Comet’ is Closing” was the title of an NPR piece last week. Except there is actually an easy and obvious answer: The show was bullied into making bad business decisions.

The New York Times covered the casting change in July in a piece titled “Diversity Concerns Prompt ‘Great Comet’ Casting Shakeup.” Well, problem solved: There are no “diversity concerns” when there is no show.

“The Great Comet” featured an excellent racially diverse cast when it didn’t have to — it’s set in pre-revolutionary Russia, after all. Yet the lead role of Natasha is played by a black actress, as is the prominent supporting role of Helene. A sad side effect of the show’s closing is that instead of one black actor losing his job, several will. How is that a win?

If the lesson becomes that black actors can only be replaced by other black actors, it will be only black actors who suffer the consequences. Is that what the race warriors want?

There’s a culture war going on out there, and it came to “The Great Comet.” Sadly, the show lost.