How to avoid plagiarism when working on an idea not developed from a student who quit the PhD program? I am doing a PhD in economics. I had an idea on an issue of my interest. With making some research, I found out that there was a previous student at my university, who did not finish his PhD, but he made an unpublished paper on the idea that I had, which has been presented at a conference, and it is not a working paper which is registered to any database.

Probably I will do something different, but build my stuff purely on this idea, but do I risk to make something just slightly different from his stuff? In this case, is it plagiarism and also unethical? How should I handle this case?
It is easy to discharge your ethical obligations here: you treat the unpublished paper like you would any other source, i.e., citing it carefully and making sure not to rewrite sentences or rehash ideas without explicit attribution (include direct quotes if necessary, and probably don't include too many of those without a very compelling reason).  

As you point out, the more serious risk is that you are starting thesis work on a problem on which someone else did a substantial amount of work on (though you worked on it independently) and that you may come out with little which is essentially new.  You're right that this is a risk: it's a risk for all thesis work everywhere.  Again my advice is to not treat this any differently than work that has been published: clearly you need to go substantially beyond it, or you don't have a thesis.  Whether the prior work of this other person shows that this is a fruitful area for you to continue in or whether it is evidence that all the good stuff has already been done is one of those tough calls that your thesis advisor should help you with.  

Finally, of course it is a shame if two people have done good work on something and neither of them publishes it.  If it turns out that you do your thesis work on something else, then as a separate project (or perhaps better: a later project), you may want to explore a publication which is a synthesis of your work and this other person's.  Offering him coauthorship would be appropriate, but if he is really out of academia then it becomes a service to the profession for you to publish the work, while accurately conveying its provenance.  It's just that that kind of publication would probably not meet the requirements for a PhD thesis (and even if it did, it would not be a good launching of your career).