(Assuming there is a god)
Why did god create us?
God created us to fellowship with Him in the Garden of Eden. He loved us so much (even before He created mankind) that He provided a solution to the problem of sin. That solution is our Lord Jesus Christ who died to pay the price required by God for our sins.
GOD DOES NOT HATE MANKIND.
If god is all knowing then god knew we would sin.
Yes, He knew we would sin. Look at it this way. God created Adam and Eve, in the garden, and then established a single question test. That test was that they could eat the fruit of every tree in the Garden with the single exception of the Tree of Knowledge of Good and evil. God told them that if they ate of that tree they would die.
Satan stepped in and convinced them that God was lying and they would not die. They ate of the fruit.
They, and all mankind, since have been paying the price for committing that sin.
God is totally righteous. He established the rules and the penalties. However, because He knew the end result He provided the solution. See above.
If god is all knowing then god knew 9/11, etc would happen.
Yes, He knew. What is your point?
If god is all knowing then god is the author of good and evil.
I am afraid your logic is a little weak in the above statement. The fact that God knows what sinful mankind will do DOES NOT MAKE HIM THE AUTHOR OF EVIL. That evil was started by Satan in the Garden. Not by God. God provided the answer to that evil. Believe in Him and His Son, Jesus Christ.
Being a righteous God, He can only deal with sinful mankind by enforcing His rules. His rules include the answer to all the evil in the world. Man is free to make his own choice. Believe or not. Simple. This is the last test (again a single issue test) for mankind. Those who pass the test (believe in Christ) will spend eternity in a far better place, where there is no evil.
Those who do not believe go to the eternal lake of fire.
As the song says
"What god wants, god gets.
God help us all".