Answer: We first need to define what sin is. A correct but incomplete definition is that it is the breaking of God's commandments or laws (Isaiah 53, Hebrews 10:26 - 27, Matthew 12:31 - 32, and so on). Sin is, however, more than that.
God's existence is a living definition of perfect love (1John 4:8, 16). This means that everything he says, does and thinks is perfect and based on a character governed solely by love. Sin, therefore, is any thought or action that God would not think or do himself.
The creator of evil
It first came into being in the mind and heart of a cherub named Lucifer. God brought him into existence possessing every positive trait, gift and advantage he could give (Ezekiel 28:12 -13, 15). Lucifer was initially a loyal spirit being who sang for joy at the creation of the physical universe (Job 38:4 - 7). All the blessings he received, however, could not keep him from destroying himself.
Lucifer, over time, started to convince himself that God's ways were not right. He began to think that the best way to live and govern everything was not through unconditional, outgoing love. A better existence, he reasoned, was one founded on self-interest and competition, ruled over through a merciless and loveless hierarchical system with himself (of course) at the top.
He obsessed over his appearance to the point where he created sin through his thoughts of vanity and lust (Ezekiel 28:17). His obsessions and increasingly perverted thinking ultimately led him to conclude that the only way to implement his ideas and fulfill his goals was to make himself ruler over all (see Isaiah 14 and Ezekiel 28). He added to his disobedience by deceiving other angels and mounting an assault on God's throne.
The First Sinner
The devil's perverted thinking and rebellious spirit spread to the human race by enticing the first humans to think as he does. The apostle Paul wrote about how disobedience and suffering entered the world when he stated, "Therefore, as by one man sin entered into the world, and by means of sin came death; and in this way, death passed into all mankind" (Romans 5:12, HBFV).
God, as the all-powerful Creator, has a right to determine what is right or wrong (good or evil) for the entire universe. He told Adam (Genesis 2:16 - 17) and Eve (Genesis 3:1 - 3) that it was good to eat from the trees in Eden with the exception of just one tree (from which it was wrong to do so - Genesis 2:17). Adam and Eve's test was whether they would believe what God said or reject what they heard and disobey him by believing something entirely different.
Adam and Eve choose to reject God's words and sin by replacing them with what they decided 'should' be good for them (eating of the forbidden fruit - Genesis 3:6). They decided that Satan's perverted thinking and distorted conclusions were correct! It is interesting to note that Eve had to convince herself (self-talk) that her own logic could determine what was best for her!
The good news is that God will, in the not too distant future, clean up the 'mess' brought by sin and its consequences (Revelation 21:4). All those who willfully choose to reject the way of righteousness will receive eternal death. Satan, the father of lies (John 8:44), will also likely be destroyed in a lake of fire where his demons will also receive their judgment and punishment.