For a purpose, I believe God created things that have the potential to be evil.
[2 Nephi 2:11-16] For it must needs be, that there is an opposition in all things. If not so...righteousness could not be brought to pass, neither wickedness, neither holiness nor misery, neither good nor bad. Wherefore, all things must needs be a compound in one; wherefore, if it should be one body it must needs remain as dead, having no life neither death, nor corruption nor incorruption, happiness not misery, neither sense or insensibility.
Wherefore, it must needs have been created for a thing of naught; wherefore there would nave been no purpose in the end of its creation. Wherefore, this thing must needs destroy the wisdom of God and his eternal purposes, and also the power, and the mercy, and the justice of God.
And if ye shall say there is no law, ye shall also say there is no sin. If ye shall say there is no sin, ye shall also say there be no righteousness. And if there be no righteousness nor happiness there be no punishment nor misery. And if these things are not there is no God. And if there is no God we are not, neither the earth; for there could have been no creation of things, neither to act nor to be acted upon; wherefore, all things must have vanished away.
And now...I speak unto you these things for your profit and learning; for there is a God, and he hath created all things, both the heavens and the earth, and all things that in them are, both things to act and things to be acted upon.
And to bring about his eternal purposes in the end of man, after he had created our first parents, and the beasts of the field and the fowls of the air, and in fine, all things which are created, it must needs be that there was an opposition; even the forbidden fruit in opposition to the tree of life; the one being sweet and the other bitter. Wherefore, the Lord God gave unto man that he should act for himself. Wherefore, man could not act for himself save it should be that he was enticed by the one or the other."
All of us have been given moral agency which is the ability to choose and act for our self. With agency, we are "free to choose liberty and eternal life, through the great Mediator of all men, or to choose captivity and death, according to the captivity and power of the devil" [2 Nephi 2:27]. Evil is when someone chooses not to follow God's plan which includes all of the laws, ordinances and doctrines of the Gospel of Jesus Christ. See also Alma 5:40-41