The colloquial phrase (just) what the doctor ordered means very beneficial or desirable under the circumstances.
The earliest instance recorded in the Oxford English Dictionary (2nd edition, 1989) is from the glossary of Rural Locutions of Maine and Northern New Hampshire, by G. A. England, in Dialect Notes (volume IV, part II, 1914), published by the American Dialect Society:
doctor ordered, what the. Something very pleasing, useful, or necessary. “She thought Ezry was jest what the Doctor ordered.”
I have, however, found 19th-century uses of the phrase.
In the following from the Brooklyn Evening Star (Brooklyn, New York) of 16th January 1852, the use of quotation marks probably indicates that the author mentions an existing phrase:
Psychology.—The lectures and experiments of Dr. Benton, at the Brooklyn Museum, are decidedly wonderful and amusing. Learned men in science and professions may wrangle about whether the power be electricity or humbug as long as they please, one thing is certain and that is, that most wonderful and useful effects are produced.
We saw last evening about thirty men, young and old, fat and lean, strong and weak, put under the influence of “electrical psychology,” as it is termed by the doctor; and in about fifteen minutes a majority of them were wholly under his control. Men having twice his muscular strength were made to lie down, sit, stand, dance, fight, sing, and in fact whatever the Doctor willed was executed without delay, and in many instances where the individual struggled to do the direct opposite of “what the Doctor ordered.”
The earliest unambiguous use of the phrase that I have found is from an advertisement published in the Daily Ohio Statesman (Columbus, Ohio) of Monday 1st April 1867:
Jake Gloss & Co.’s Lunch.—The only lunch set in this city can be found to-night at the saloon and restaurant of Jake Gloss & Co., No. 13 West State street. After electioneering all day, you will find a good bowl of soup, or a cold lunch “just what the doctor ordered” to rest and refresh you. Soup ready at 9 o’clock.
The second-earliest instance that I have found is from the same newspaper, the Daily Ohio Statesman (Columbus, Ohio), of Saturday 11th May 1867:
The Metropolitan Police Law.—The argument on the prayer of the City of Columbus for an injunction, was continued before Judge Green yesterday. […] The forenoon was consumed by Attorney General West, in a long, labored and specious argument to prove the correctness of Judge Baldwin’s argument of the day before, that the Court had no jurisdiction of the case, and that the law is perfectly constitutional, right, and in fact “just what the doctor ordered.”
In the following from The Dundee Advertiser (Dundee, Scotland) of Monday 30th August 1880, the laughter and the remark made by Lord Craighill, who presided over the court, seem to indicate that (just) what the doctor ordered was also in use in Britain at that time; this newspaper reported that during the trial at Perth of Alexander Anderson, “charged with forging the signature of Archibald M’Neill, grocer, Crossgates, to a promissory note for £20”, M’Neill had declared:
About the time the prisoner called and asked him to sign a bill he was taking a “table-spoonful” every night, but that was just what the doctor ordered. (Laughter.)
Lord Craighill—What the doctor ordered is a very common phrase. (Laughter.)
The following also seems to indicate currency of the phrase; on Saturday 11th December 1880, The Northampton Mercury (Northampton, Northamptonshire) published an article on an entertainment organised by the temperance movement called the Independent Order of Good Templars:
I.O.G.T.—An “open Lodge” of the Excelsior Good Templars was held at the Poplars, on December 3rd. R. Littleboy, Esq., presided. Programme:—Part song, “Hurrah! for Temperance”; reading, part of a “Speech by John Hockins, forgeman,” Miss Henderson; reading, “How my wife signed the pledged [sic] for me,” Mr. F. Littleboy; reading, “The publican’s net,” Mr. Cousins; part-song, “The wanderer’s farewell”; reading, “What the doctor ordered,” Mrs. Goodman; duet, “The footsteps on the stairs,” Mrs. Snowden and Mrs. T. Higgins; [&c.].
On Saturday 11th November 1893, The Era (London) mentioned that, at the West London Theatre, on Church Street,
Mr Ted Young makes a good impression with his songs “Keep it up,” “It wasn’t what the doctor ordered,” and “Only a pensioner.”
An unambiguous use of just what the doctor ordered appears in City Notes, published in The Sketch (London) of Wednesday 4th October 1899:
Echoes from the House.
The Stock Exchange.
“Consols1 are flat!”
The sound of the words is bad enough at any time, but when they are spoken in a political crisis, and on an average some hundreds of times per diem, they have a peculiarly depressing effect all round the Stock Exchange. The Kaffir2 “boom” when it comes will be heralded by a rise in Goschens3, and at their present price of 104 Consols look almost cheap. These columns have borne testimony over and over again to the absurdity of the stock standing at 110, but the sharp fall from that quotation—and the stock at one time this year touched 111½—has brought down the Funds to buying price. Money is likely to temporarily become a little easier during October, and the political outlook is a transient influence which no more affects the actual credit of the country than would a war between Saturn and Jupiter. So that, for anyone with “money over” who doesn’t mind a low grade of interest, Consols at their present price are just what the doctor orders.
1 The word consols is a shortening of consolidated annuities.
2 On the London Stock Exchange, Kaffir denoted a share in a company that runned mining operations in southern Africa.
3 Goschens was a colloquial name for consols after their conversion from 3 to 23/4 per cent in 1888 by George Joachim Goschen (1831-1907), Chancellor of the Exchequer (1887-92).
This lends credence to the following remark made by the police officer, journalist, editor and author Cecil Rolph Hewitt (1901-94) in London Particulars (Oxford University Press, 1980):
Grandma Hewitt was a walking repository, rather than a dictionary, of clichés and catch-phrases; and I have often wished she could have been known to Mr Eric Partridge4 during the compilation of his delectable dictionaries. Both she and I, and I’m sure my brothers, could pre-date many of Mr Partridge’s attributions. Here are four examples, none of which he places earlier than 1945 and yet all of which were common currency in my Edwardian5 childhood: ‘Just what the Doctor ordered’, ‘Are you kidding?’, ‘Cheats never prosper’, and ‘All behind like a cow’s tail’.