We get the English word "sin" in the KJV Old Testament from two main Hebrew words. The definition of the word chattath (Strong's Concordance #H2403), first used in Genesis 4:7, is "an offense." The second word, chata (Strong's #H2398), which first appears in Genesis 39:9, means "to miss." Brown-Driver-Briggs states it is to miss the way, goal or path of right.
The New Testament, like the Old, also has two main original language words that are translated as "sin." The word hamartia (Strong's #G266), which appears 174 times in the Greek text, is the act of committing an offense (transgression). The second word, hamartano (Strong's G264), occurs 43 times, is "missing the mark." These terms are roughly equivalent to meaning, "to make an error or wander from the path of uprightness" (Thayer's).
The most basic way to understand sin is that it is any thought, attitude or action contrary to God's will and his perfect character of love. It includes the breaking of any of his commandments (1John 3:4, Romans 7:12 - 13, James 2:10 - 11, etc.), whether in "the letter" (their narrow interpretation based on what is written) or in their spiritual intent.
Scripture also defines this behavior as knowing to do good and not doing it (James 4:17) as well as anything not done in faith (Romans 14:23). All unrighteousness is considered sinful (1John 5:17). It should be noted that since God is the standard by which all that exists is measured and judged, all transgressions are foremost against him (Psalm 51:4) even when they greatly affects others.
Letter versus Spirit
Jesus, after selecting the twelve men who would become his inner-circle of disciples, gave his most often-quoted message known as the Sermon on the Mount. One of the main goals of this message was to reveal the full intent of sin as taught in the Old Testament.
One of the teachings Jesus expanded upon was the seventh commandment, found in Exodus 20:14, which forbade the sin of adultery.
You have heard that it was said to those in ancient times, 'You shall not commit adultery.' But I say to you, everyone who looks upon a woman to lust after her has already committed adultery with her IN HIS HEART (Matthew 5:27 - 28, HBFV).
Jesus' teaching offers an excellent contrast between what God required under the Old Covenant and the depth of obedience expected under the New Covenant. A "letter of the law" interpretation of the seventh commandment states that the physical act of sex outside the marital union is sin.
Jesus' explanation, however, shifts the focus of disobedience to a person's thoughts and attitudes. Sin is now imputed to humans (whether they are married or not!) if they harbor lustful thoughts toward another person, even if they do not act upon their strong desires!
Why does it matter?
Why is God not only concerned about the external (physical) manifestations of sin but also the internal thinking and attitudes that lead to them? It is because man was created with the potential to live forever in a spirit-based, not flesh-based, body!
All humans who repent, build character through obedience, and stay faithful to the end, will be resurrected. They will then be given spirit-based bodies in order to live forever. Each human has the potential to receive the same spirit-based existence and righteous character as the Godhead.
Sin separates man from God and cuts him off from the one relationship needed in order to learn how to live a full and productive life - both now and in the future. This breach can only be healed through the sacrifice of Jesus Christ.
Through repentance and accepting his sacrifice as payment for our disobedience, we can establish a close and personal relationship with our Maker and Father. Believers are guaranteed they will be forgiven, and continue under his grace, as they seek his will in their lives.
Consequently, there is now no condemnation to those who are in Christ Jesus, who are not walking (living their lives) according to the flesh (following human nature's inclinations to sin), but according to the Spirit (meaning God's righteous way of living - Romans 8:1, HBFV).