Or "the serpent" if you don't think it was Satan.
Either way, free will only applied to humans, which means he could have prevented the whole "sin/misery/death" thing by just tossing the reptile out before it ever met Eve.
God knew it would happen, and he just walked off to play Minecraft or whatever, knowing there was a serpent who would Rube-Goldberg humanity into misery.
Read more:
If God knows all why did he let Satan into/stay in the garden of Eden?