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.
It seems that the real question should be "why the title of doctor seems to be now more associated to medical sciences than other fields".
Doctor comes from doctum, that is a derivative of docere, Latin verb for "teaching". The first doctors in the very first universities studied in four faculties: arts, medical sciences, law and theology. We still use PhD (Philosophiae doctor) but the meaning of the word philosophy has changed over the centuries. During the renaissance, the word philosophy had a broader meaning since philosophy at that time encompasses the whole spectrum of science.
In some countries (France for instance), it is forbidden to use the title of Dr for those who are not MD. In this case, Dr is a degree but not a title. Why do we not use MD everywhere instead of Dr (which seems to be the way to suppress the ambiguity while respecting history)? I don't know.