First, I would say we just do not know much about Satan. Some here refer to him as "Lucifer" but that is based on a poor translation from the KJV of Isaiah 14:12 which turned a Hebrew phrase that means something like "son of the morning" into a proper name. It is also not clear that Isaiah 14 or Ezekiel 28 have reference to Satan. They are prophecies about earthly people. Some of the language seems to go way beyond what could be said about these earthly people, but it is also poetic language that is filled with hyperbolic imagery. So it is possible that Ezekiel and Isaiah were describing a majestic fallen angel who would later be known as Satan and using his fall as an objective lesson for the prideful rulers being judged in those passages, but we simply cannot be sure of that.
The word "Satan" simply means adversary or enemy. It is more of a descriptive noun or title. It is not a proper name. This is why Jesus called Peter "satan" in Matthew 16:23, because at that moment Peter was opposing Christ's mission. He had become an adversary (a satan) to the will of God. I doubt it was anything more than that, despite the common line that Jesus was calling Peter the devil (especially when we consider the fact that the devil was instrumental in having Jesus killed, which is the opposite of what Peter was saying here). In fact, the angel of the LORD is called a "satan" in the OT when he opposed Balaam while on his way to Balak. Numbers 22:22 says, "But God was angry because he was going, and the angel of the LORD took his stand in the way as an adversary [literally: as a satan] against him." So much of what is said in Christian circles about Satan is based more on Christian folklore, tradition and speculation than strict and explicit Biblical data.
However, I do think we can assume that Satan was at one time an angelic being, and God certainly did create him. But the idea being brought up here is that God created him specifically as an enemy, and that is not the case. Whatever he was when he was created, he was not evil. At some point this being chose to rebel against God. This might have even corresponded with the fall of man. Satan fell when he tempted Adam and Eve to sin, possibly because he was jealous of the dominion God gave them over the earth, or the special status they had as being made in God's image. Who knows (and this would make sense of Jesus saying he was a "liar from the beginning", meaning the beginning of the world, not the beginning of his existence).
So this being turned on God at some point (again, possibly in his act of tempting Eve Adam and Eve). Did God foreknow this when he created him? I think so, just as God foreknows our rebellion. But this does not mean God caused him to rebel. And it is not like God could "not create" him based on foreknowledge of his future rebellion, because that would end up falsifying God's foreknowledge of him as created being who would eventually rebel (since there would then never be such a being for God to know anything about), and God cannot be wrong.
So the answer is similar to why God created us, knowing we would fall. He created us for good purposes and with good intentions, but we fouled that up. But he gifted us with freedom so we could have a genuine relationship with Him, not so we could sin against Him. However, God knew we would misuse the gift of freedom he gave us and made provisions for our redemption. But why not beings like satan and other fallen angels? Well, we just don't know. The Bible doesn't tell us. It could be that as purely spiritual beings with direct knowledge of God and a higher form of intelligence, such decisions would end up being irrevocable for them, so that once such a decision was made, there could be no turning back. But again, that is all speculation. The main point is that God did not create the being that would be later known as satan so that he could have an enemy. While he would indeed become God's enemy, that was not God's purpose or intention for him when he was created, just as it was not God's intention for Adam and Eve to disobey in the garden.