Where does the title Dr come from for PhD? I have always wondered why a person is given the title of Dr after completing a PhD in a non-medical field. This is especially because of the confusion over the medical title of Dr. Why hasn't a better distinction been formulated by now?
It's actually exactly the opposite: "doctor" is Latin for "teacher" and the title originally had no special connection with medicine.  Instead, a doctor was anyone qualified to teach at a university (in medieval Europe teaching qualifications were typically determined by the church).  The concept of a formal PhD degree came much later, but it continued this earlier terminology.

The confusion in English is irritating, but not problematic enough to make universities give up a 1000+ year old tradition.  It's not clear why this situation arose.  One natural explanation is that if you want to emphasize your medical skills, you can do it by explaining that you are not just a healer, but in fact someone qualified to teach other people the healing arts.  In other words, you're a doctor of medicine in the academic sense of the word "doctor".  Until very recently universities were fairly exotic, and most people didn't talk about academic doctors very much, so the medical usage was much more salient for the general public and for most people it became the standard meaning of "doctor".

Of course this difficulty with this story is that it doesn't explain why, for example, German does not confuse the terms the same way English does.  Maybe it's just chance, or maybe there's some cultural reason.

In any case, though, academia had the title first and is reluctant to change it.