@Caleb hit some very important points. I think that this question, however, is an offshoot of a common objection to Christianity:
"How could an omnipotent God who hates sin allow sin. If He's omnipotent, couldn't He have prevented us from sinning?"
The answer to that, of course, is that God gave us free will because He loves us, and because He wants to be loved in return. Our love for Him wouldn't be real love if it were forced. We'd be little better than robots, programmed to behave a certain way.
The answer is so simple and so obvious that people gloss over it looking for a more "meaningful" answer, but the simple fact is that throughout scripture, love is the defining aspect of goodness. Jesus Himself said this. (Matthew 22:36-40)
Even in our limited human mental capacity we can understand this without giving it much thought at all. If you have children, think about this: They are disobedient, stress-causing, wallet draining beings, but would you trade them for a mindless robot programmed to act like the perfect child? Unless you're inhuman (or having one of those days with them), the answer is no. And the reason is because you love them in their imperfection, and they love you.
Their love is worth all of the hassles they cause for you. When they obey willingly and cheerfully, it brings you pleasure, it brings them pleasure to know they've please you, and brings you closer together.
This is why God gave us free will and gave us the capacity to sin. So that when we obey willingly and love Him of our own free will, it brings Him and us true joy, and is the ultimate definition of "good".