It's the sort of element a writer or playwright usually adds in the story whenever it looks like one or more of his characters are hopelessly, irremediably screwed, and the ending is supposed to be a happy one. Its primary purposes are saving the day and filling the gaps in the story. Accounts for lack of creativity when it comes to situations.
The term means "god in the machine" and originated in Greek theaters, where playwrights frequently used a godlike character, carried by some sort of mechanisms, for the purposes mentioned above.

