There is a particular trope that became quite infamous across many media: the "it was just a dream" revelation, where, usually at the end of a important story arc, everything turns back to the start since nothing actually happened in the real world and the story narrated in said arc is thus erased. It may have consequences on the dreamer psyche, of course, but the fictional world is not changed by the story.
It is my understanding that this trope is perceived as "cheap" in many cases. It's so infamous that it's used as an inside joke sometimes; "yea, they all die in chapter 6, and then they wake up in chapter 7". Yet, I see that this trope is a still used narrative device and I'm wondering why.
So, my question is: What are some good reasons to use the "It was just a dream trope"? What are some situations were it can be used effectively?
I'm struggling to understand why would an author want to use that. I suppose it can be useful to write yourself out of a corner, but it seems an huge waste negating a good part of a story this way. Also it's my opinion that the dream-trope utterly shatters the reader trust and suspension of disbelief. So, again, when is it worth to risk it?