God
Why did God create Satan if he knew Satan would turn against him?
Scripture never actually walks through this in detail. That's worth noticing before trying to answer it. The Bible doesn't give a clear, step-by-step story of how or why Satan turned against God. It mostly shows him already opposed to God, without explaining how that began.
Some Bible passages are traditionally read as pointing to a rebellion among angels. But those passages were originally written about human kings. Christians have long debated how directly they apply to Satan.
The Bible is clearer about a bigger idea: love that's real has to be chosen freely. Beings who can genuinely love God can also genuinely reject him. Christians believe that's true of humans, and was true of angels too.
Knowing in advance that a choice might go wrong doesn't make it less of a real choice. That doesn't erase the difficulty here—it's a real, old question. But it explains why Christians don't see it as a flat contradiction.
Bible quotations in these answers are generally taken from the Christian Standard Bible®, Copyright © 2017 by Holman Bible Publishers. Used by permission. Christian Standard Bible® and CSB® are federally registered trademarks of Holman Bible Publishers. Some biblical wording may be paraphrased or follow other translations.