If we say that we haven't sinned, we make him a liar, and his word is not in us.
The second reason why he wrote this epistle is in chapter 2, verse 1 John 1:1 . "These things write we unto you, that ye sin not." And so, the purpose of this epistle is to bring to you a life of victory over sin, to give you power over sin.