One must not peer into the heart of man. For the heart is ever-questioning. Up to two times can be forgiven. But one who cannot answer the heart's third question... Will fall into an eternal slumber.
The World (differentiated from the real world with a capital ‘W’) is also often referred to as a Dream by the various characters due to its incredible nature and thus, they are often interchangeable but the World isn’t actually a dream. Here, every soul that winds up in the World are called Alice regardless of their real name or their gender.
In reality, the World is actually a manifestation of the hidden parts of a person's heart. The doors to a person's World is often locked on the outside because no one wants or likes having their inner hearts intruded upon but they're unlocked from the inside, requiring no key to open the door.
Trespassing upon a person's World has grave and adverse consequences on both that person and the trespasser no matter how careful one tries to be. The riddles presented in each of the Worlds could be thought of as locks or safety measures that protects against intruders and prevents them from proceeding which is why only an outsider could solve the riddles. The horribleness of having them forced open by an outsider who then touches the parts of a person's innermost heart that they never wanted touched is usually enough to break or destabilize them.
The damage to the psyche is so guaranteed that it's to the point where the only way to save an Alice is to not enter their World in the first place. But once in the World, the outsider only has three chances to answer each riddle presented to them. If they fail to answer correctly all three times, they'll be killed or die.
Despite the horridness, Fiona has said that the heart can't hurt you in a Dream. She says the simple reason why Allen is in the World is because he lost XXXX (love) regardless of what Cheshire might say about it.
Given this, it's implied that the World is in fact the afterlife supported by the cemetery theme of the main area, the fact only souls wind up in the World, the presence of the sky of souls, and the fact that Stella has figured out that people die without love and all the children has had love stolen from them by Cheshire while Teacher is oblivious to it.
It seems the "gateway" to the World is through Nightmare Syndrome and there are only two ways out of the World: Either make a pact with a demon, fusing both souls into one and thus creating a link between the World and the world, or using the key with the sharp point to stab someone, unlocking the link and turning the target into a door. However, using the latter method means their soul won't be able to leave the World, making them prey to Cheshire. The target's body in the real world then slips into a coma.
Cheshire also presents the question of who the creator of the World is, asking if this is a Dream, then who's Dreaming? It might actually have been Teacher even though Allen was apparently the one who opened his door. He had stated that he wanted to go to the World alone, which might mean he became victim of Nightmare Syndrome, supported by the headaches he gets. As a result of his door opening, all the other children got taken in as well, causing the entrance to become bigger.
It might be that someone of a higher power (the "God" Cheshire mentions in the Cheshire Cat ending) created a space which embodies the hidden parts of an "Alice" (which might actually refer to people who lost love) and set up some rules (which remain unclear) after people forgot XXXX following the world's creation.
Anyone who ventures into the World will mold it according to their own hearts. This might explain Cheshire's contradicting points at the beginning when he said that whatever Allen does and says goes and since he says it's a dream, the World is a Dream and yet insists that Alice is Alice because Cheshire says so since, as a guide and therefore part of the World, he follows different rules.