The rings were created by Digory's Uncle Andrew using magic dust that had been left to him in a box by his part-fairy godmother, Mrs. Lefay. Instead of destroying the box as his godmother told him to, Uncle Andrew started experimenting with the magic dust, out of which he eventually forged his rings. The dust originates from the Wood between the Worlds. Some of that dust wants to return to the Wood, while some of it wants to get away. This explains why the yellow rings take you to the Wood and the green ones take you out of it.
Bearing in mind that The Magician's Nephew, like all of the books in The Chronicles of Narnia, is a Christian allegory, one could say that Uncle Andrew's experiments are meant to show us the dangers of people acting like gods and messing around with dark forces they don't fully understand.