All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Allaah The Almighty created the universe in accordance with certain norms and laws that emerge from His wisdom. This wisdom also necessitates the existence of miracles, like for instance the splitting of the moon for the Prophet, sallallaahu ‘alayhi wa sallam, holding the sun back (from setting at sunset time) for Yoosha' (Joshua) the fire being cool and secure for Ibraaheem (Abraham) and the splitting the sea for Moosa (Moses) . Moreover, there are miracles that are yet to come like those that will occur through the Antichrist as a trial for mankind, and the rising of the sun from the west as a sign of the Hour. All such miracles and supernatural events occur with a command from Allaah The Almighty and also conform with His wisdom and knowledge.
There is great wisdom behind the constancy of the norms that control the universe as well as behind the miracles and supernatural events that violate these norms. Allaah The Almighty Says (what means): {He is not questioned about what He does, but they will be questioned.} [Quran 21:23]
Allaah Knows best.