This is explained in The Magician's Nephew.
Digory Kirke had an uncle, Andrew Ketterley, who had a fairy godmother, Mrs Lefay:
[Andrew] "My godmother was a very remarkable woman. The truth is, she was one of
the last mortals in this country who had fairy blood in her. [...] In
fact, Digory, you are now talking to the last man (possibly) who
really had a fairy godmother."
Before dying, she gave him a box from Atlantis which contained dust from another world:
[Andrew] "She had got to dislike ordinary, ignorant people, you understand. I do
myself. But she and I were interested in the same sort of things. It
was only a few days before her death that she told me to go to an old
bureau in her house and open a secret drawer and bring her a little
box that I would find there. The moment I picked up that box I could
tell by the pricking in my fingers that I held some great secret in my
hands. She gave it me and made me promise that as soon as she was dead
I would burn it, unopened, with certain ceremonies. That promise I did
not keep." [...]
[Andrew] "The Atlantean box contained something that had been brought from
another world when our world was only just beginning. [...] Only dust.
[...] If only you could get it into the right form, that dust would
draw you back to the place it had come from. [...] At last I succeeded
in making the rings."
Andrew made two kinds of rings: yellow and green. With the former you can go to the Wood between the Worlds, with the latter you can go from there to any world:
[Digory] "No, I don't believe this wood is a world at all. I think it's just a
sort of in-between place. [...] Think of our tunnel under the slates
at home. It isn't a room in any of the houses. In a way, it isn't
really part of any of the houses. But once you're in the tunnel you
can go along it and come into any of the houses in the row. Mightn't
this wood be the same?—a place that isn't in any of the worlds, but
once you've found that place you can get into them all." [...]
[Narrator] Uncle Andrew, who knew nothing about the Wood between the Worlds, had
quite a wrong idea about the rings [...]. The stuff of which both were
made had all come from the wood. The stuff in the yellow rings had the
power of drawing you into the wood; it was stuff that wanted to get
back to its own place, the in-between place. But the stuff in the
green rings is stuff that is trying to get out of its own place: so
that a green ring would take you out of the wood into a world.
Andrew coerces Digory and his friend Polly into testing the rings. They go to a world called Charn, where Digory awakens the malicious Queen/Witch Jadis. Digory and Polly attempt using the rings to run away to Earth, but since she is touching them, she is transported too. They attempt to take her back to Charn, but they make a mistake:
[Jadis] "This is not Charn," came the Witch's voice. "This is an empty world. This is Nothing."
Then the Lion, Aslan, creates Narnia in that previously empty world:
[Narrator] In the darkness something was happening at last. A voice had begun to
sing. [...]
[Narrator] One moment there had been nothing but darkness; next
moment a thousand, thousand points of light leaped out—single stars,
constellations, and planets, brighter and bigger than any in our
world. [...]
[Aslan] "Narnia, Narnia, Narnia, awake."