The Bible never directly addresses this question - I guess that’s largely because the Bible is fundamentally a book about rescue - it tells us how we’ve gone wrong with God, and how Jesus came to put us right with God. The urgency of this message (and how we respond to it) means that a number of abstract, perplexing, philosophical-type questions are left unanswered. The serpent turns up enigmatically in Genesis chapter 3 without any introduction.
I’m going to approach the question at a fairly abstract level, but I don’t want to give the impression that this is a passionless issue. It cuts right to the centre of all the evil, pain and suffering we see in our world. And this is not something that leaves God unmoved. He cares so much that he was prepared to come to earth in the person of his son, Jesus, and be put to death so that all this evil could be dealt with. The question raises the issue of why God let any of this happen. We may not be able to answer that fully, but we can know one thing for sure: its not because he doesn’t care.
Having said all of that, let me give some thoughts. Your question, Why did God let the Devil exist is related to other questions like Why did God allow sin to ever happen? I think both of these tap into an important issue often described in terms of God’s sovereignty and our responsibility. Bear with me for a moment, I’m going to come at your question in a roundabout way.
God being sovereign means that God is completely and utterly in control of everything. Nothing happens outside his plans.
Us being responsible means that when we do things wrong, we are responsible for them. We are responsible because we do want we want to do. When we sin, no one has forced us to do something that we were totally opposed to.
Joseph speaking to his brothers about them selling him as a slave, Genesis 50:20 - “You intended to harm me, but God intended it for good to accomplish what is now being done, the saving of many lives.” The brothers did evil (and were responsible for it) and yet at the same time God was in control and using this event to bring good.
Most profoundly of all, Jesus’s death on the cross, Acts 2:23 - “This man was handed over to you by God’s set purpose and foreknowledge; and you, with the help of wicked men, put him to death by nailing him to the cross.” The chief priests wanted to kill Jesus, and they did so, and they are responsible. But at the same time God was bringing his purposes about - He had always intended that Jesus would die, an innocent man giving his life to accomplish the saving of many lives. God had always intended that the chief priests would put Jesus to death - God is sovereign AND they are responsible.
It is important to hold sovereignty and responsibility together. Deny Gods sovereignty and he is no longer God. Deny our responsibility and we are no longer human (more like robots).
With the devil, the issues will be similar. God created humans and angels with the ability and responsibility to worship and serve Him. In the beginning, God created everything good. God did not create robots which were unable to do anything but follow their programs - God created responsible agents who were free to worship him willingly. The devil was not evil to start with, but chose to rebel against God. God is still in control, and the devil is responsible for what he has done.