Sin is anything that contradicts God. It is an offence and the opposite of righteousness.
In the same way that the government has laws, and when people break those laws, they commit an offence, sin is an offence committed against God. Sin is often thought of as breaking the Ten Commandments and the other rules set out in the Old Testament (murder, adultery, stealing, worshiping idols). But Jesus actually tells us that sin is everything that falls short of God's perfection.
In Matthew 5, Jesus explained what sin truly means from God's perspective by comparing the true meaning with the common understanding:
"You have heard it said, 'You shall not murder ... but I tell you that anyone who is angry with a brother or sister will be subject to judgement.'"
"You have heard it said, 'You shall not commit adultery. But I tell you that anyone who looks at a woman lustfully has already committed adultery with her in his heart.'"
"You have heard it said, 'Love your neighbour and hate your enemy.' But I tell you, love your enemy and pray for those who persecute you".
Jesus tells us that our previous understanding falls woefully short, and that even the slightest deviation from God is sin. He's saying that, yes, murder and adultery are sins, but so are holding a grudge (unforgiveness), lust, and hatred. Jesus is saying that sin is not the outward action, but the inner workings of our heart.
Doesn't that make God impossible to please? Yes and No.
Yes, because imperfect beings (people) cannot please a perfect God. The moment we deviate from perfection, we fall short and become incompatible with God. But this truth isn't a bad thing; it's a statement of God's greatness.
And no, because God knew we would be incapable, on our own, of being able to co-exist or please Him. He never intended to leave us to our own devices. Instead, He created us knowing and promising to make a way for us to co-exist and please Him.
God knew that no matter how many 'good' deeds we did, it would never be enough to wipe away the bad (there might be 1000x more 'good' than bad, but it does not erase the bad). Consider the crime of murder. When a person commits murder, he is a murderer forever. He can turn his life around and be a good person, but that blemish - that crime - will never be undone. It's the same with sin. The moment we sin, we carry that blemish with us forever. And it's for that reason that we are incompatible with a perfect God.
While that may be hard to hear, it is the reality of perfect goodness; perfect goodness cannot coexist with anything that falls short.
Knowing this, God sent His son, Jesus, into the world to redeem us - to make a way for us to coexist with Him. Now, instead of relying on our deeds (which fall short), we rely on Jesus, and when we do, God imputes His perfection onto us. It's simple and yet so difficult to understand. God loves us and wants us to experience perfect love. The only perfect love that exists is in Him. He says, 'Just know me - know that I am God and you are not, and you will be with me forever.'
In Isaiah 43, we read, "But now, this is what the Lord says - he who created you, he who formed you: 'Do not fear, for I have redeemed you; I have summoned you by name; you are mine. When you pass through the waters, I will be with you; and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned; the flames will not set you ablaze. For I am the Lord your God, the Holy One of Israel, your Savior ... Since you are precious and honored in my sight, and because I love you ... Do not be afairad, for I am with you ... Bring my sons from afar and my daughters from the ends of the earth - everyone who is called by my name, whom I created for my glory, whom I formed and made ... You are my witnesses ... and my servent whom I have chosen, so that you may know and believe me and understand that I am he. Before me no god was formed nor will there be one after me. I, even I, am the Lord, and apart from me there is no savior.