It is actually a metaphor for grace and miracle, the suspension of natural law through an act of spiritual authority culminating in a reinforced moral order. Bad magic in traditional stories represents the evil power that the wicked use in order to grasp at what does not rightly belong to them whether worldly power, wealth, or even love. It is also a metaphor for the intervention of the enemies of God the evil spirits, in the lives of wicked men. Good magic and bad magic in truthful stories correspond to true religion and false religion in our real world. True religion is the search of the soul for God in order to surrender itself to him, the search for his will in order to fulfill it, the search for truth in order to conform to it.
False religion is the inverse.
True religion is about surrender, while false religion is about control. Most of us do not learn about the nature of reality through theology, philosophy, or higher mathematics. But all of us readily grasp the language of a parable drawn from the universal human story. The forms may be dressed in elaborate costumes and enact impossible dramas, but they enable the lover of tales to step outside of himself for a brief time to gaze upon his own disguised world. A rare objectivity and insight can be imparted regarding this world's struggle for spiritual integrity.