The ancient American Prophet Lehi taught that righteousness must be opposed by wickedness. Here are his words:
For it must needs be, that there is an opposition in all things. If not so, my first-born in the wilderness, 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 nor misery, neither sense nor insensibility.
The world teaches many falsehoods about agency. Many think we should “eat, drink, and be merry; … and if it so be that we are guilty, God will beat us with a few stripes, and at last we shall be saved.” [ 2 Nephi 28:8.] Others embrace secularism and deny God. They convince themselves that there is no “opposition in all things” [ 2 Nephi 2:11.] and, therefore, “whatsoever a man [does is] no crime.” [ Alma 30:17.] This “destroy[s] the wisdom of God and his eternal purposes.”
Source: 2 Nephi 2:11; The Book of Mormon: Another Testament of Jesus Christ