To portray the Gods in plays, the Classical Greek actors were lifted in the air using a huge lever system. This is precisely the deus ex machina: an actor portraying a god, hanging from a lever machine.
Of course the audience could see the rope and the lever, but hey, this was early days for special effects. The audience had the imagination to blot out the mechanics. They wouldn't be able to guess which god they saw, but the actor would declare his identity in his opening lines, and the play carried on.
Mary Renault uses this to good effect in The Mask of Apollo. In that story, her hero is an actor playing a god. The audience gasps and the actor looks up to see what the audience can see: the rope is frayed and will snap at any moment and he'll fall to his death. So he does what any good actor would do: he carries on with his lines.
The mechanics of the system worked fine, but there was a problem with the way the Classical playwrights used their divine characters. The gods tended to appear at the opening to set the scene, then they'd disappear, only to suddenly return right at the end and close down the story before it could reach a climax. It's like the writers included too much plot and simply chopped the story off using divine intervention when time ran out.
The technique was so notorious that deus ex machina has come to mean anything which shuts down a story suddenly and without warning, in a completely arbitrary way, thus preventing any natural resolution for the characters.
Euripides was a serial offender when it came to deus ex machina.
I can't help feeling Euripides was born into the wrong time and place. He should have been born in the 20th century, where he would have been totally at home writing post-modernist mainstream literary. Euripides essentially had no interest in plot whatsoever. The plot for him was merely a vehicle to carry his beautiful words and exquisite phrases. If he got to the end of what he wanted to say before the story finished...not a problem. He just introduced a god or goddess as a character, suddenly, at the end, and with no rationale whatsoever, to tie up all the threads of the plot in one momentous speech. Then everyone could go home.
Ion is a good example of his perfidy. In that story an orphan called Ion seeks his true identity. The plot becomes a trifle convoluted. There's a false prophecy which totally confuses everyone. Ion meets his mother, all unknowing to them both. She tries to kill him a couple of times (these things happen). He takes a shot at her too. Then Athena turns up for the first time in the story, and in a single speech reconciles everyone and explains away the early false prophecy with a very dodgy throwaway line. Mother and son for some reason think it's cool that they're related, despite recent homicidal attacks, and everyone lives happily ever after. No natural resolution.
This is almost as ridiculous as following for six years a group of people trapped on an island, with all manner of deep symbolism, intricate plot threads and exotic clues, only to close with a happy, happy, joy, joy ending and all the intricate threads left loose. No one in their right mind would write such an ending these day—oh, hang on...scrap that.