I've had a similar story to yours, except for the fact that I was involved with a man for several months, not as long as you have, but I hope this story helps.
This guy lied non-stop. I got involved with him and he was living with his girlfriend, who he said he was in the process of breaking up with. He told me your typical stories such as he hadn't had sex with her in 5, 6, 7 months (the numbers kept changing each time he told them), he slept on the couch, etc etc. Well, the usual things to get a gullible female such as myself in bed.
He told other stories, as well. At first, I thought he was just exaggerating stories to impress me, but the stories got more and more incredible, such as the one where he was incarcerated by accident in Syria and had to do a job interview on the phone from jail...
I think he just wanted to have an affair, but it got out of hands when I just wouldn't put up with him being involved with me when he was still with someone else. I tried to break it completely off several times, but he claimed again and again that he needed me, he was in love with me, but his circumstances were very difficult, etc, etc. I have a soft spot for broken people, so I thought I could help "fix" him, so I took him back.
The last elaborate lie he told me was that his girlfriend was pregnant of 2 months by him ("so, how long was it since you last had sex with her again?"), so we couldn't be lovers anymore, since he wanted to give his relationship a chance. This could well have been true but, given his past history, I really doubt it. I think he was just trying to get rid of our relationship because he couldn't stand the guilt of what he was doing to his woman and wanted me to think of him as someone who was doing "the right thing".
Well, now this catch of a man wants me to be his good friend and stick by him in these difficult times. I walked away from such a poison in my life. I'll let his poor girlfriend deal with him.
What I'm trying to say is DO NOT BE THERE FOR HIM! He needs someone who enables him, he is seeking your attention just for his own ego, someone who cares for him and is always there because he is too afraid of who he really is (hence, all the lying to cover his inadequate self up). The only thing that you sticking by him will lead to is that your self-esteem will go below zero, you'll be hurt by all his constant lying, never knowing what's true and what isn't and going nuts, while he will be feeling great.
You shouldn't try to understand why he lies, since that will weaken your resolve to walk away from the situation because you'll start feeling sorry for him. Whatever reasons he has to be lying (personality disorders, bad childhood, etc) that's his problem, not yours. If he wants to be helped and change, he should seek professional help.
I hope this helps some. At least you know you're not alone in your story and you shouldn't feel stupid because you believed him. I was also suckered in by the lies! And so have many, many victims of compulsive liars.