The answer to the question of why God would create someone knowing he will go to hell is found in Romans 9:21-23 which says,
“…does not the potter have a right over the clay, to make from the same lump one vessel for honorable use, and another for common use? 22 What if God, although willing to demonstrate His wrath and to make His power known, endured with much patience vessels of wrath prepared for destruction? 23 And He did so in order that He might make known the riches of His glory upon vessels of mercy, which He prepared beforehand for glory.”
So, according to the Bible, it seems that God patiently endured the "bad" people so that He could express His great riches upon the people who go to heaven. These evil people freely choose to be evil, and if God were to stop them from existing then He would have to, in effect, stop people from being born who would never hear the gospel and who would reject the gospel.
But still, even the people going to hell can have a purpose in this life. There are many non-Christians who have advanced medicine, technology, and helped other people a great deal. God has ordained that they perform work which is ultimately for His glory since he has blessed even the lost with gifting – in accordance with them being made in God’s image. But, they reject God and are without excuse (Romans 1:20).
Finally, there is a logical problem with not creating people who go to hell. It would mean that no one would go to heaven. You see, without the crucifixion, no one could be saved. But, in order for Jesus to be crucified, evil people had to lie about Him and murder Him. His crucifixion is the means by which we are saved. So, if God doesn't create people He knows will go to hell, then there would have been no crucifixion by which people could be saved. In that case, all people would go to hell. Therefore, if God was to not make anyone who would go to hell, then He would not make anyone at all.