If we say that we have no sin, we are deceiving ourselves and the truth is not in us. If we make it our habit to confess our sins, in his faithful righteousness he forgives us for those sins and cleanses us from all unrighteousness.
Some scholars believe John was alluding to to the Nicolaitanes sect. Nicolaitanes believed that the freedom and forgiveness given to children of God meant that nothing was forbidden, and they could do whatever they pleased. Whomever John had in mind, the principle is timeless. There have always been those who supposed that their own sinful conduct was justified, either maintaining the right to act in whatever way they please or holding that as forgiven Christians they are perfectly sanctified and guiltless. John is clear - anyone who claims to be without sin lies and cannot truly be guided by the source of all Truth. If there is a true work of God on our souls we cannot help but sense the filth of our own hearts.
The whole Gospel of Jesus is founded on the truth that all have sinned and fall short of the glory of God. No amount of good works can redeem. For this reason the incarnation was necessary. For this reason Jesus came to earth to teach, suffer death on the cross, and resurrect to redeem.
Though we are freed from the guilt of sin because Jesus' blood covers and his righteousness justifies, we are not without sin. Thank God that if we confess and acknowledge our sins he continues to forgive and sanctify us. He is just to forgive our sins, not because it is an act of justice but because he is true to his promises. He has promised to redeem his people, and he will hold up his end of the bargain whether we do or not.
In addition God cleanses us from unrighteousness by purifying our hearts and conforming us to the image of Christ. The longer we walk with Christ and are guided by the Holy Spirit, the more likely it is that we will put away our overt sins. We teach children the ABC's of salvation - Admit, Believe, Confess. The first and most basic step in becoming a Christian is admitting our own sins and shortcomings. But as we continue our walk with Christ we must continue to admit our sins as often as we become aware of them.