God is supposed to be all knowing and all powerful,which means he knows everything and everyone, the Devil did not just happened God made him knowing very well that the Devil will bring nothing but Evil, so why made him in the first place?
The Devil or Satan is introduced in the Garden story. The Garden of Eden was written allegorically. Satan was also a symbolic creation. In the Garden allegory, Satan is confined to the earth which means the physical world, specifically he is doomed to slither along the ground. The physical world is the world where physical man resides. Later in the allegorical story, man is given dominion over all living things including that which crawls or slithers along the ground. However you define Satan or evil(defining and naming things is our job too), its all on us.
Free will....wait....mankind created god(s) in our own, human imagine with our own human faults & foibles because we needed a way to explain natural phenomena that was, at the time, beyond our understanding & it was scary. We kept god(s) around because humankind is inherently weak & needs a reason/excuse/scapegoat for when we fuck up (the devil made me do it) instead of taking accountability. The powers that be saw religion was an excellent control mechanism for the unwashed masses & made it a cultural pillar to keep them chained in obedience & threstened with loss of heaven. Hopefully, those chains are weakening.