Depending on usage, it can be used to move the story forward when the writer has "painted herself into a corner" and sees no other way out, to surprise the audience, or to bring a happy ending into the tale.
Depending on usage, it is primarily used to move the story forward when the writer has "painted herself into a corner" and sees no other way out. However, in other cases, it is used to surprise the audience or, commonly influenced by editors or publishers, to bring a happy ending into the tale.