The wikipedia article has some interesting history:
"Doctor is an academic title that originates from the Latin word of the same spelling and meaning.[1] The word is originally an agentive noun of the Latin verb docēre [dɔˈkeːrɛ] 'to teach'. It has been used as an academic title in Europe since the 13th century..."
"In the United States, the use of the title "Doctor" is dependent upon the setting. The title is commonly used socially by physicians and those holding doctoral degrees;[57] however, there was formerly a division between Letitia Baldrige and Miss Manners on its social usage by those who are not physicians.[58] Baldrige saw this usage as acceptable, while in contrast, Miss Manners wrote that "only people of the medical profession correctly use the title of doctor socially," but supports those who wish to use it in social contexts in the spirit of addressing people according to their wishes."
https://en.wikipedia.org/wiki/Doctor_(title)
https://en.wikipedia.org/wiki/Doctor_(title)#Development_in_...
https://en.wikipedia.org/wiki/Doctor_(title)#United_States