"What purpose could evil possibly serve?" you asked.
Well, first note . . . that without God--if there is no God as described in the Bible--this very question is meaningless gibberish. It is BECAUSE there is a God that such a question is even possible.
For one thing, if there is no God then there can be no "purpose" and no "evil." We are just walking matter, sputtering meaningless noises , randomly "existing" for a moment's flash, then returning to dissolution into dirt and eventually chaotically bouncing molecules . . . . Oh, we can construct and maintain some temporary goals and preferences, but they have no transcendent, ultimate meaning.
God says in His Word that we actually all know in our hearts that He exists but that we "suppress that knowledge in unrighteousness." We are rebels, pride-filled, selfish and stubborn and do not want to submit to anyone other than our selves . . . .
A major problem in "Seeing" these truths and understanding them, is that "a fool says in his heart there is no God" . . . while "the fear of the Lord is the beginning of wisdom/knowledge." So, unfortunately, it is difficult, if not impossible to understand anything in any meaningful, truthful way, without first submitting to and following God.
As one who Believes and thus, worshipfully "fears" the Lord . . . I can tell you, for one thing, "evil" sends us running . . . into the arms of God. There is a purpose I can tell you exists from experience. As I mentioned earlier, when we persist in comfort and ease and prosperity (of health, wealth, pleasure etc.) we strongly tend NOT to look for or care about God. Who needs Him? But this is a dangerous illusion as it is only because of God (the One Who creates all and provides everything we use and need; air, water, food, shelter, family, friends, talents etc.) that we exist in the first place and have whatever it is that we have to enjoy.
But the blind fool with the "heart of stone" imagines he himself is responsible for what "blessings" he enjoys, takes credit for them, and succumbs inexorably to lording it over others, boasting, ignoring the sick, poor and needy (unless to give to for vanity's sake and more self-righteousness chest pounding) . . . and before you know it a whole life is spent on temporal, pointless, self-serving adventures with not a thought or care given towards the TRUE Author of all . . . let alone, any thought or gratitude given to what Jesus went through to take away our sins and give us eternal life. . . .
So, "evil" is allowed to roam about, like a hungry lion, bringing deprivation, pain, suffering, misery in various forms . . . for the PURPOSE . . . of turning people back toward their God, their Father Creator. As it is only from Him that all "blessings" can derive, and only according to His laws and love that creation is capable of living in actual, ongoing peace, joy, prosperity . . . then "evil" is used as a way to powerfully clarify the situation, such that it becomes obvious to us--we, who otherwise are quite dense and delusional when left to our own devices and faulty wisdom. . . .
Here's the thing . . . . Indeed, the main thing that kept me searching and questioning and testing all of the various and diverse "spiritual paths" or religions I genuinely investigated and applied. . . . It was wanting to know the answers to just such "hard questions." And, in fact, some of the "answers" I found in a few of the "Eastern" religions were quite satisfying intellectually, ie., related to the "problem of evil".
Problem was . . . however . . . that none of them "worked." By that, I mean, regardless of the answers I found to satisfy my intellect, the overall philosophies/teachings and practices of the different religions . . . never really CHANGED my character (heart) in the way that was promised and in the way that I was deeply craving. Not if I was honest with myself, despite my growing knapsack of mystical knowledge and even "supernatural" experiences.
I finally realized, when God showed me the actual ongoing depravity, falsity, hypocrisy--SINFULNESS--of my real, inner, hidden heart and self . . . that NONE of these various other "paths" had the power to transform and save me . . . from my self. One, however, above all DID.
It came like a clear, dawning realization. Jesus IS "the way, the truth and the life" . . . exclusively!
Now, I still had a lot of questions--as I yet do today--but once I set some of those aside and finally just submitted and followed God as revealed in His Word . . . those questions became secondary. Interesting, but not crucial to the reality of now knowing that God IS . . . and that He is the God of the Bible. I did not need to have them answered to experience that Jesus is the Savior of mankind.
Also, what I have found out, is that He does give answers . . . in time, over time, as He sees fit, and it is only SINCE I have been invested with the light and wisdom of the Holy Spirit . . . that I can actually see and understand them properly. Before I was dead and blind. Now, I am alive and the Spirit of Truth shows me all kinds of things that I wondered about before but only had the dark, misguided, muddled and fanciful notions of fallen MEN or myself to supposedly guide me.
Anyway, please note, if there is no God, then it is irrelevant and nonsensical to ask what purpose there might be for so-called "evil." "Evil" would merely be some relative "construct" . . . devised by squawking chemical matter bags with no ULTIMATE meaning and purpose. "Evil" is a moral idea which presupposes ABSOLUTE right and wrong, good and evil.
If there IS a God, then I easily assume that He has perfect and good purposes for allowing "evil" whether I can comprehend them at this point (or ever) in my ongoing existence.
In the meantime, I can see a number of good purposes God is making out of the presence and work of "evil" in this world--such as, to drive me into the protective, saving arms of the Lord daily and to keep me humble and pursuing His Word. . . .