The cliche of this comes less from published fiction, and more it often being 'baby's first twist ending'. Like... literally in third grade, we had a writing unit, and multiple kids did the "it was all a dream" thing.
There are interesting ways to do a dream ending, but the question is what it adds. I understand the perspective of "it's a story, so why would you be upset that it's a story in a story", but that's not the way most people experience fiction. Readers cry for beloved character, gasp over twists, want to solve puzzles, want logic and consistency. We see ourselves and our loved ones and our teen bullies reflected in imaginary people. The fun of a story is buying in. "
It was all a dream endings", in their bad form, tend to be the first resort of inexperienced writers who know they want to shock readers and throw a twist, but haven't gotten past what the reader will feel beyond "I didn't realize that!" If it's not used for anything, most readers will feel betrayed, like they've been told to care, then laughed at for caring. It doesn't make all the pieces come together in a way that adds meaning, in a way that makes every action more complex and fascinating in retrospect, it subtracts meaning.
It's complicated because we can buy into framed fiction. The Princess Bride, for example, is framed as fiction in story. The 2006 movie 'The Fall' is powerful BECAUSE it's a reflection of the characters telling it, a wandering tale of a desperate man filtered through the mind of a child.
When the tellers aren't influencing much of the story, like the movie of The Princess Bride, we are buying into two separate stories. First, we buy into the story of a grandfather connecting with his grandson, second, we are buying into a grand adventure/romance with pirates and rodents of unusual size.
When the stories weave together, we buy into one story. The emotions, the characters, become 'real' to the reader. After all, we are creatures that love stories, that try to fit the real world into stories, and so the stories become different facets of a single narrative.
Good dream and coma narratives often follow the rules of woven stories. The dream isn't a second story, it's a place for characters to actually learn and progress. That's why twist ending examples are rarely worthwhile. The 'real world' has no arc or meaning. The dream world is what we've given meaning, and that's just been destroyed. Would Wizard of Oz be satisfying if it was just a girl in a magical land who, at the end, hits her head and winds up in Kansas? The point is that she starts in Kansas, spends the entire story trying to return, and finally does, with a new sense of love for her home.