If the supreme creator has infinite wisdom, then why create both good and evil? Why not only good? Most people would be happier if the world was only good.
Both good and bad are properties of a dualistic world. They are anthropomorphic ideas and do not apply to the Divine.
The world consists of the illusory duality of knowledge and ignorance. It contains of knowledge and devotion, and also attachment to 'woman and gold'; righteousness and unrighteousness; good and evil. But Brahman is unattached to these. Good and evil apply to the jiva, the individual soul, as do righteousness and unrighteousness; but Brahman is not at all affected by them.
One man may read the Bhagavata by the light of the lamp, and another may commit a forgery by that very light; but that lamp is unaffected. The sun sheds its light on the wicked as well as on the virtuous.
You may then ask, 'How, then can one explain misery, and sin and unhappiness?' The answer is that these apply to the jiva. Brahman is unaffected by them. There is poison in a snake; but though others may die if bitten by it, the snake itself is not affected by the poison.
The Gospel of Sri Ramakrishna, Chapter 3, Visit to Vidyasagar, August 5, 1882
It is simply the property of evil that anyone who does evil is eventually punished while it is the property of good deeds that people who do good deeds are eventually rewarded. The idea is that if you eat chilli then you will feel the heat.
Another analogy is that of a forest that contains both trees yielding sweet fruits and trees yielding bitter fruits. The presence of both types of trees has no effect on the forest. A human must, however, avoid the trees yielding bitter fruits.
Now that we have established that evil applies only to Jivas, then the next question is why should there be evil?
Neighbour: "Why has God created evil people?"
Sri Ramakrishna: "That is His will, His play. In His maya there exists avidya as well as vidya. Darkness is needed too. It reveals all the more glory of light. There is no doubt that anger, lust and greed are evils. Why, then, has God created them? In order to create saints. A man becomes a saint by conquering the senses. Is there anything impossible for a man who has subdued his passions? He can even realize God, through His grace. Again, see how His whole play of creation is perpetuated through lust.
"Wicked people are needed too. At one time the tenants of an estate became unruly. The landlord had to send Golak Choudhury, who was a ruffian. He was such a harsh adminstrator that the tenants trembled at the very mention of his name.
"There is need of everything. Once Sita said to her Husband: 'Rama, it would be grand if every hoiuse in Ayodhya were a mansion! I find many houses old and dilapidated.' 'But my dear,' said Rama, 'if all the houses were beautiful ones what would the mason do?' (Laughter.)"
The Gospel of Sri Ramakrishna, Chapter 2, In the company of devotees, March 11, 1882