In answer, I will assume this question is referring essentially to sinful humans and fallen angels (or demons). So, rephrased, what I understand this question to be asking is how a perfect God could have created sinful people.
Self-described Christians generally offer, to my knowledge, one of three answers to this.
1. The answer I have heard most commonly is that because the God of the Bible upholds the value of love first and foremost (Deuteronomy 6:5, 10:12; Matthew 22:37-40; Romans 5:8, 8:38-39; 1 Corinthians 13; 1 John 4:7-8), and because love cannot exist apart from free-will (can your computer really love you?), and because free-will cannot exist apart from the genuine option to do good or to do evil, the ability to do evil was necessary to grant to humanity (and angels) so that the option of genuine love could be possible. Thus, a perfect God, desiring nothing less than the love of His creation, created them in such a way that they had the genuine capacity to choose to love and accept Him or to choose to hate and reject Him. So, in this view, God Himself did not create sin, He only created the capacity for sin. God here takes on a passive involvement rather than an active involvement in the existence of sin or imperfection. He is simply "letting" it happen rather than actually "making" it happen.
Critics of this first answer would say that the concept of free-will is not only utterly absent from the Bible but also contradicts numerous passages (see answer 3 below), and at best can only be gathered through the implicit deduction shown above -- namely, if real love, then free-will to do good or evil. Critics further argue that it minimizes the authority of God and the power of God -- He doesn't seem to have any power over what people will do -- and thus makes trusting in God pointless. Martin Luther, writing in his book "The Bondage of the Will", declared that if a person believes in free-will, then they believe that God is not in charge, therefore it is impossible for them to have faith in Him, and thus they cannot be a genuine Christian.
2. The second way this question is commonly answered is to simply say that it is a mystery. God Himself is beyond our comprehension (Job 37:5; Isaiah 55:8), and thus we cannot expect to understand everything about Him. This is simply one of those things we can't understand. Generally, this answer is given by those who reject answer 1, yet cling to the idea that "God is not the author of sin", a phrase not found in the Bible.
Critics of this second answer suggest that it is not a mystery because the Bible makes it perfectly clear.
3. The third way this question is occasionally answered is that God actively (not passively) causes people (and angels) to sin because, through their sin, His perfect justice and overwhelming mercy are made known to His creation (Romans 9; Proverbs 16:4; Job 1; John 12:39-40; Exodus 9:12, 10:1; Deuteronomy 2:30; Lamentations 2:6; Isaiah 63:17; and compare 2 Samuel 24:1-10 with 1 Chronicles 21:1).
Critics of this view hold that it makes God the author of sin, ignores God's holiness and perfection, and denies the reality of free-will.
After holding to answer 1 for many, many years, I now find myself agreeing with answer 3, even though it makes many Christians extraordinarily uncomfortable. It does not ignore God's holiness or perfection in any way for Him to cause others to sin, and, as Martin Luther taught, the term "free-will" really only accurately applies to God Himself.
From a Biblical perspective, sin is defined as disobedience to the command of God. God the Father does not command God the Father to do anything, so God the Father never disobeys God the Father's commands, thus God the Father is perfect and without sin. God the Son and God the Holy Spirit always obey the commands of God the Father, so again, God is completely without sin. To believe, as the verses referenced above teach, that God causes people to sin, is not to make God a sinner. Thus, His perfection, holiness and sinlessness is never infringed upon.
Further, James 1:13 states: "Let no one say when he is tempted, 'I am being tempted by God'; for God cannot be tempted by evil, and He Himself does not tempt anyone." This is frequently quoted to support the concept that God does not cause people to sin. However, it only states that God Himself does not tempt, which means to try to get someone to sin... to try to convince them that they should disobey God. Obviously, God doesn't "try" to do anything. He either causes things to happen or causes them not to happen. God does not tempt, but that certainly doesn't mean He does not cause people to sin, as seen in the scriptures listed above.
We must also note that "imperfection" is really in the eyes of the beholder. For example, a sphere would not be perfect if it had any pock mark upon it. Nonetheless, our planet (a sphere) would be less perfect if it did not have the Grand Canyon (a pock mark) to explore.
So, in sum, it seems to me from a Biblical perspective that our perfect God created imperfection simply because it was the perfect thing for Him to do.
But it doesn't stop there -- He also chooses to save us from sin through His Son Jesus. In most religions, man must sacrifice his prize possessions to bless God. In Christianity, God sacrifices His prize possession to bless man.
If you have not put your trust in Jesus Christ, there is no better time than now. The Bible states that if you confess with your mouth that Jesus is Lord and believe in your heart that God raised Him from the dead, you will be saved (Romans 10:9). God will then transform you, and you will then know how to truly love (1 John 4).
Comments
What if the old testament was not written by men influenced by god, but by men influenced by Satan? They believed it was god speaking to them, as would anyone writing the words they did not create themselves. Maybe the true god is meant to cause peace and love, while his nemesis attempted to confound him with nonsense laws, prejudice, and the image of a manic-depressant deity?
(this was not meant to start an online war, please take this comment as my opinion, if you wish to debate it with me please do :D
Let me explain.
All God desires is for man to choose him over sin, in my understanding that means he wants us to make a conscious decision to love him and obey him above all our worldy desires.
Who is more cruel... God or man?
God places some here in sickness, deformed, enslaved, starving, poor and in need vice versa or in between. That isn't love, it's sad.