There is a certain sense in which it can be said that God did not create the devil. God created the archangel Lucifer, who was created good and who was given the free will to love and to serve God. It was Lucifer who “created” the devil when he abused his free will by choosing to separate himself from God.
As for God’s knowledge, God is omniscient, so he did indeed know which choice Lucifer would make. But had he not created Lucifer, or had he not given Lucifer free will, then Lucifer could not have freely chosen to love and to serve God. Even knowing that Lucifer would fall, God loved Lucifer enough to allow him to exist and to have that choice.