Let's put it in context.
I moved back to Newville last year, and I was glad to be back home. I had lived there twenty years ago, and then I started traveling.
This is kind of possible, but I don't like the adverb "ago" in that sentence. I would simply change "ago" to "before", and then I think we have a much more plausible sentence.
I moved back to Newville last year, and I was glad to be back home. I had lived there twenty years before, and then I started traveling.
now - 2009
last year - 2008 - I had lived there 20 years before - 20 years before I moved back there in 2008, which was 1988
twenty years ago - really twenty years before 2008 - 1988
This context shows that the speaker lived in Newville 20 years prior to moving back, which was 1989. It's logical, then, to use the past perfect because the speaker is stating that one time frame - action or event - happened or took place before another time frame - action or event - in the past, and not up until now.
Expressing the idea of "up until now" the job of the present perfect, of course.
Let me know if you have a follow-up question. This is an interesting question because ELLs have, in my opinion, a somewhat of a challenge when it comes to knowing when the right time is to use the past perfect. Or more simply put, they have somewhat of a difficult time incorporating it into their English, especially spoken English.