The ability to lie and not realize it is a gift unique to humans. Not only do we deceive others, we can trick ourselves into believing something that's not true is. That's because motivation for lying is usually tied up in self-esteem and self-preservation. We lie in an effort to create the best possible version of ourselves, and we lie so that we don't have to face the consequences that our other, less-perfect self incurs. That means we may lie about our accomplishments or skills so that others respect us more, or to cover up mistakes so that we don't lose that respect. We'll also lie about mistakes and misdeeds to avoid punishment. Sometimes we do it to avoid hurting someone else's feelings, which has the bonus effect of ensuring the other person maintains their good opinion of us -- and doesn't become consumed with a desire to break our nose.
We lie because it works, and because it has benefits. We avoid punishment by fibbing about who scribbled on the walls with permanent marker, we get higher raises by taking credit for work tasks we didn't complete, and we get love by assuring a potential mate that he or she doesn't look fat in those jeans. When lying ceases to work (when the lie is discovered) and has more drawbacks than perks (your spouse won't look at you after discovering your extramarital affairs) -- only then do some people tell the truth.