The idea of other worlds besides this one (in fantasy, that means other “dimensions” or other frames of reality, not merely other planets – usually) is a very old element of fantasy, and it has several different roots.
On one level, the idea of having the fantasy action take place in some other reality that the protagonists reach through the hidden doorway, the magical summoning, or a similar means is a way to have all sorts of wildly wonderful storytelling elements while preserving a comfortable view of our own world as one in which magic doesn’t happen and everything is controllable and “normal.” It’s also a way of letting the imagination run wild without it being constrained by the limitations of current reality.
The need to preserve a non-magical Earth has pretty much disappeared from fantasy writing today, and one doesn’t see that so much; in fact, the genre of contemporary fantasy or urban fantasy dispenses with other worlds altogether and places the fantasy elements in our own, which actually makes it a lot more like the ancient and Medieval myth-making (Greek myth, Arthurian legend, the Arabian Nights, etc.) that did the same.
The desirability of a freewheeling canvas hasn’t changed, though, and that means many fantasy stories are still set in alternate worlds, either reached from this one by magical means or simply “the world” inhabited by the protagonists who have no knowledge of our own. That is one perfectly good and literarily sound reason to employ the other-world convention in a fantasy story, but there are some other aspects to it that touch on the spiritual dimensions of fantasy, too.
Before going into that, let’s deal with the variants on the other-world concept as it appears in fantasy.
Travel from here to there: In this conception, the protagonists come from our world but the story takes place in another world to which they travel by magical means. C.S. Lewis’ Narnia chronicles, and, via the cross-genre device of space travel, his Deep Space trilogy (which is fantasy, not science fiction, despite this), Steven R. Donaldson’s Thomas Covenant series, and many others follow this convention.
It all takes place there: In this conception, the protagonists are natives of the other world rather than visitors. The other world is simply the world of the story, with its own history, its own laws of nature, and its own culture. Tolkien’s stories, Robert Jordan’s Wheel of Time series, George R.R. Martin’s Song of Ice and Fire, and really too many others to list all approach things in this way. It’s probably the most common approach to fantasy fiction out there.
Multiple worlds interacting regularly: This conception is superficially like the first one, but it posits two worlds that interact on a more routine basis than the hardly-every-happens premise in which the protagonists go to a world where hardly anyone has gone before. One finds this in more than one form. The worlds may be magically-separated, a more-magical world of Faerie linked to a less- (but not necessarily non-) magical world where the protagonists live ordinarily, or they may be technically in the same world but separated by some other device, e.g. the Shadowlands in Tad Williams’ Shadowmarch stories.
The point I’m making in all of these descriptions of the elements of fantasy is that fantasy is myth-making and bears a resemblance to and connection with religion and spirituality. The connection here lies in religious and spiritual ideas of other worlds than this one: Heaven and Hell, the Astral Plane and other ideas of multiple planes, layers of reality underlying the one that we see with our normal consciousness. Two things about the world are suggested by this myth, in the usual metaphorical, sidewinding fashion of all mythos.
1) There are aspects to reality which are not seen normally because our vision is blinded by our preconceptions, our cares and concerns, our narrow-minded focus on the simple and the mundane. Whole worlds exist right before us, but most of us cannot see them.
2) The world may become something which is not envisioned by most, either something much better, or something much worse, but in any case something radically other, and it will. The limits of the human imagination blind us to the possibility of true change.
These two aspects of the mythic message are powerfully connected. We are able to access other worlds to the extent our minds are open, and fantasy fiction provides a way to open our minds while preserving a measure of safety, in that we recognize we are dealing with fiction and can fool ourselves about its significance for the real world.
That other worlds and other possibilities impact the one we live in is, or should be, obvious. If nothing else, we live in a human-shaped world where the power of the imagination is the strongest single factor influencing the reality we live in, bar the laws of physics themselves, and they act more as a limit than as a true shaper; they determine what cannot be, but within those limits the imagination determines what will be. That’s recognizing only the impact of the imagination as mediated by human physical action, not any real-world magical effect.
The importance of the other worlds of fantasy, regardless of the precise mechanism employed by the storyteller, lies in their significance for our lives in this one. They may create a backdrop for the telling of mythical and moral tales; they may present metaphorical images of layers of reality intersecting with our own but unrecognized. At minimum, they invite us to broaden the scope of our imagination and expand the limits of our consciousness, and engage in mythical thinking, which is always of spiritual significance.