Wikipedia states on a disambiguation page that "the good doctor" is "a cliché referring to any physician." However, the earliest link on that page is to the Wikipedia article on Dr. Samuel Johnson (1709–1784)—while the earliest occurrence of "the good doctor" in a Google Books search is from almost a century before Johnson's birth. A biography of Thomas Fuller (1608–1661) attached to a three-volume set of his works dated 1662, refers to Fuller as "the good doctor" more than a dozen times, but it seems have been written sometime in the 1800s.
The Google Books search results for "the good doctor" show six matches between 1620 and 1700, distributed across the years 1620, 1655, 1658, 1662, 1687, and 1693. Here are the details of those earliest matches. From Samuel Hieron, "The Preachers Plea," in The Sermons of Master Samuel Hieron (1620):
It is a good saying of an ancient Father to this purpose : If my predecessors (saith he) either by ignorance or by simplicitie haue not kept and holden that which our Lord hath taught them by his example and authoritie, the mercie of our Lord might pardon them. But as the good Doctor saith, We cannot hope for the like, hauing better meanes of instruction. When the outward ordinary meanes failed, Gods hand was not shortned, but he was able euen in the midst of blindnesse, to saue those which belonged to the election of grace.
Unfortunately, I haven't been able to identify the "ancient Father" who (I assume) is the same person identified as "the good Doctor" in the next sentence. One possibility is that "Doctor" as used here refers to a "Doctor of Divinity."
From John Sargeant, Schism Disarm'd of the Defensive Weapons, Lent It by Doctor Hammond, and the Bishop of Derby (1655):
His thirteenth [chapter] is of St. Paul, who (saith he) appealed from the judgement of the chief Priests to the Tribunal of Cæsar. So as now Cæsar, a Heathen Emperor, is become Head of the Church; nay of two Churches (according to Master Hammond) the Heathenish, and the Christian. But the good Doctor is most grievously mistaken here, as he hath been almost in every place of .Scripture he hath yet produc't; & I observe, that though he be pretty good at mistaking all over his Book, yet when he comes to alleadge any thing out of Gods Word, he errs far more accurately.
The interesting thing here is that "the good doctor" is already being used sarcastically to describe, with exaggerated politeness, an enemy, Dr. Henry Hammond (1605–1660).
From William Sanderson, A Compleat History of the Life and Raigne of King Charles (1658), referring to events of August 1644 involving the siege of Hereford and its garrison commander Sir Barnabas Scudamore:
The wise men were admitted, and their secret counsel and advice was, To render up all to the valiant Scots; and so they parted. And the good Doctor [Doctor Scudamore] bringing them out of the Port had an unfortunate Shot from the Scot that killed him.
This being a sympathetic account of Scudamore's defense, it seems reasonable to take the characterization "the good doctor" here at face value.
From John Fell, The Life of the Most Learned, Reverend and Pious Dr. H. Hammond, second edition (1662):
Accordingly the good Doctor [Hammond] attended on his Master [King Charles I) in the several removes to Woburn, Cavesham, and Hampton-Court, as also thence into the Isle of Wight, where he continued till Christmas 1647.
This is one of eight instances of "the good Doctor" that Fell uses in the course of this book; Hammond is, of course, the same person whom John Sergeant ridicules as "the good doctor" in 1655. Since the first edition of Fell's work was published in 1661, five years after Sergeant's effort, it may be that "the good doctor" was a sobriquet applied to Hammond by his friends and admirers.
From Thomas Tenison's 1688 translation of Jean La Placette, Of the Incurable Scepticism of the Church of Rome:
How near to the truth doth the good Doctor [Canus (?)] approach? For first, he rejects not the Opinion of the Cardinal ; which if admitted, will soon put an end to the Controversie. Secondly, by the last clause of his Answer he confesseth that a Council free, and using requisite diligence, may pronounce contrary to the Faith.
From Stephen Nye, Considerations on the Explications of the Doctrine of the Trinity (1693):
They say farther, that 'tis not to be much regarded that so many have complemented Dr. Wallis for his Letters; for what Assurance have we that the Writers of them are not secret Socinians, and that they only banter the good Doctor?
All six of the earliest matches for "the good doctor" in Google Books search results appear to involve doctors of divinity, most of them (naturally enough) in the context of religious disputes. It doesn't seem to great a stretch to imagine the phrase "the good doctor" being associated in the first instance with religious figures like Thomas Fuller and Henry Hammond, and then with scholars like Samuel Johnson, and finally with physicians and scientists like the heroes of Dr. Doolittle and Dr. Who.