Why did God create some people to punish them?

God has created everything with a purpose. He wanted to reward and test the people. He created Hell and He created Paradise. If he put them all to their destined places immediately, the people of the Hellfire would have an excuse against Him and His Justice; being punished for something that they'd not even done yet. And so He gives the people free will and the opportunity to do what they wish, which includes evil, and says:

"Whoever comes with a good deed will be rewarded tenfold. But whoever comes with a bad deed will be punished for only one. None will be wronged." [6:160]

So while people commit monstrosities & transgression against Him or His Creation, He allows it and is merciful to them regardless, sometimes to the point of giving them the elite luxuries of this world despite how much they ridicule or disobey Him; and then even says:

"He will forgive your sins, and delay your end until the appointed time. Indeed, when the time set by Allah comes, it cannot be delayed, if only you knew!" [71:4]

So Allah has allowed them on the Earth to do whatever they wish, but to Him is their final return, and it is there where everything will be brought in front of them.