From H Roy Elseth’s Did God Know:
…that the absolute prevention of evil would have made our world not better than it is, but infinitely worse. There are three conceivable ways in which evil could have been prevented: 1) God might have refrained from creating beings capable of sinning; or 2), having created such beings, He might have kept them from temptation; or 3), allowing them to be tempted, He might have forcibly prevented them from yielding. First, suppose that He had created only beings incapable of sinning. That would have been to create nothing higher than a brute.