Mu’jizah (miracle) is an Arabic word that comes from the root Ajz (inability). A Mu’jizah is an action that others are unable to do. A Mu’jizah is proof of a prophet’s assertion that he has been sent by God.
Mu’jizah is also called Kharg Aadat (breaking with the usual course of things). Although it has similarities with magic, sorcery, etc, it is different from them in that Mu’jizah is never defeated as it has divine origin.
The messengers of God used miracles as a means for guiding and educating people not for entertaining them.
Moses (AS) is among the prophets who demonstrated many miracles during his life. One of his miracles was defeating sorcerers and magicians employed by pharaoh.
On a day when a large group of people had gathered in the city, the sorcerers and magicians used all their abilities and slyness to defeat Moses (AS). They threw their sticks and ropes on the ground and it became a seething sea of serpents, writhing and slithering.
For a moment, Moses (AS) worried that people would believe the magicians and pharaoh. He also worried that people would not recognize the difference between magic and miracle.
He immediately threw down his staff and suddenly it turned into a real serpent, devouring all the other supposed snakes.
Here, the truth was made clear to all and the magicians prostrated right there to profess their belief in God and confess to their inability and powerlessness before God’s power.
So the educational effect of this event is quite clear as the magicians immediately believed in God.