I can’t tell you when the idea of a spoiler alert emerged, but the Greeks didn’t have this issue. In fact, they had the opposite: knowing the story in advance was the norm.
Theatre emerged from the practice of people performing dithyrambs, or choral odes retelling myths that were famous among the Greeks. Everyone knew these stories, but there are a million ways you can write a song about the same story, so each song was different. During the annual Festival of Dionysus (or Dionysia), held in Athens in the spring to celebrate the harvest, honor military things, and generally get drunk, there was a competition for companies across the city to see who are the best dithyramb-performers. Dionysia was a civic and religious festival, the second most important Athenian festival after the Panathenaic Games, a religious and athletic festival.
Theatre emerged from dithyrambs as a way of making this more interesting: rather than being told a story, audiences would get to see it played out. Legend has it that the personal responsible for this was a late-6th century BCE performer named Thespis, the first person to break from the chorus and act as a character in the story, embodying someone entirely different, though the truth to this story is in question. Nevertheless, theatre emerged as a popular art form: it started as just one actor interacting with a chorus, but over the course of the fifth century, playwrights started making room for two, three, and even four or more actors.
Tragedy was the primary form of theatre, as it was the retelling of myths and history. Comedy had more original stories, but also was a smaller part of the theatre experience—it wasn’t added to the Dionysia until the middle of the fifth century, whereas it was more common in a smaller festival, the Linnea.
So because the plays were based on popular myths, there wasn’t much room for spoilers. It’d be like going to see a play today about King Arthur and being surprised that he wields Excalibur—it’s almost expected you know it, but you want to see how this production presents the journey that leads to him getting the sword. After all, different playwrights often based plays off the same myths: Aeschylus and Sophocles both wrote plays about the Theban royal family and their many problems, while Sophocles and Euripides both wrote separate plays called Elektra. Aeschylus's Oresteia trilogy was based on parts of The Iliad, an epic poem that audiences were very familiar with, but tells the story differently than the plays. All these writers were writing from the same basic source material, and were competing to tell the story better.
But even if you didn’t know Oedipus marries his mother, you couldn’t really have the play spoiled. This is because seeing plays back then was largely a one-chance situation. Playwrights would present their play at Dionysia, but it wasn’t frequently remounted during that time period. Last year, when theatre and civilization still existed, you could see Oklahoma! on Broadway, or see a regional production, or a bad student production, or watch the filmed 1998 version, of the movie from the 50s—the options to see some version of the story are limitless—but you also have a lot of time to do so, because the productions last longer than a single night or a single performance. But Dionysia occurred only once a year, and while there were some smaller festivals that might have seen earlier productions of these great plays, that was the major source of theatre for people. If you didn’t see the play at Dionysia, you likely never saw it. Which means no one could spoil it for you: if they saw the show and you didn’t, then they can hold that over you for the rest of your life (like my friends who saw Great Comet do to me) because you never will have the opportunity. The Theater of Dionysus could hold about 17,000 people; Athens had a population of 200-300 thousand people, about 30,000 of whom were adult males. Dionysia was incredibly popular, but of course not everyone had the chance to attend.
In the fourth century, Dionysia started seeing remounts of older great plays, likely to create a nostalgia for the past. And we know from the writings of people in this period that the scripts of some plays were available to those wealthy and educated enough to access them, since people discuss both the stories and the writing styles of some plays. So it’s possible that later in Greece’s history, spoilers would become possibly; 4th century theatre and beyond are outside of my wheelhouse for the time being, unfortunately.
———
I wrote this on my phone right before going to bed. I apologize for any typos and whatnot.
Edit: Cleaned up and clarified some stuff that my 1am brain didn't write as well. Get good sleep, kids.