Why does God create evils and the devil?

If Allah wants me not to commit evils, then why does He create evils and the devil?

Creating the evils is not evil but committing evil is evil

Doubtlessly, not the creation of a “knife” itself, but committing evils with the “knife” is evil.
Everything in the universe serves goodness and fineness unless man misuses them. When he misuses anything in the universe, however beneficial and beautiful they are, they turn into depredation and evil for him.

 

Is it reasonable to abandon numerous good so as to avoid minor evils?

Rain is the lifeblood of earth but; it is inevitable for a lazy and careless man’s leaky roof to get damaged because of rain. Is it fair to consider the creation of rain and fire as evil because of leaky roofs and carelessness of man?
If the rain had been abolished from the earth for the purpose of avoiding a few minor damages, it would be the epitome of the evil and the end of the world!

 

Evil and devil are created to increase the level of man

Even the creation of devil is good; but following his way is evil

There are good purposes in the creation of devil, as well.
In this world where we come to be tested, human will either fall to the lower levels than the animals by following the devils or raise higher levels than the angels by striving against the devil and the evil. It’s up to his will to convert the consequences of the opportunities he is given into good or bad.
For detailed information you may see the article entitled“ The Purpose of the Creation of Evils and the Devil” .