The spirit (if not the exact wording) of the expression appears in print in John Oldmixon & Dominique Bouhours, The Arts of Logick and Rhetorick, Illustrated by Examples Taken Out of the Best Authors, Antient and Modern, in All the Polite Languages, Interpreted and Eplain'd by That Learned and Judicious Critick, Father Bouhours (1728):
Henry IV. of France, said something as strong as this to his Soldiers, before the Battle of Iv'ry. I am your King, you are French Men, and there's the Enemy. We read in Livy, that Camillus the Dictator had a saying to the same Purpose. Hostem, an me, an vos, ignoratis? Know ye not who the Enemy is, who I am, and who you are yourselves? Great Minds often think alike on the same Occasions, and we are not always to suppose, that such Thoughts are borrow'd from one another when exprest by Persons of the same heroick Sentiments. They carry Conviction along with them, compel our Judgement, stir our Passions, and leave a Sting behind them in the Soul.
A number of nineteenth-century authors expressed the proverb in its familiar shorter form, well before 1890.
From a brief item in the [New York] Literary American (August 25, 1849):
GREAT MINDS THINK ALIKE.—The Rev. Greville Ewing, of Glasgow, had a work on theology ready for the press when Professor Dwight's of America, was issued, and so similar were its views and language to the manuscript of Mr. Ewing that the latter had to renounce the publication of his, although it had cost him many years of mental and physical toil. This shows that minds similarly constituted, in the examination of like subjects, arrive at the same, or nearly the same conclusions—although they may be separated like these two eminent men, by the broad ocean.
From Virginia De Forrest, "How Euphrosyne and Pete Daffodil Became Literary," in Godey's Lady's Book (April 1856):
"Here is a quotation—'The course of true love never did run smooth.' SCOTT. Did Scott write that, Annie?"
"Go on with the story," I replied; "never mind who wrote the quotation. Great minds think alike; and I dare say Scott and Shakespeare both had this idea."
From "Judge Law and Jeff. Davis on the Confiscation Bills," in the Daily Evansville [Indiana] Journal (September 18, 1862):
I hope you will call the attention of his friends to the policy of circulating large numbers of this speech to aid in his election, and to assuage the asperities of this cruel and barbarous war against the poor rebels. In the meantime I take the liberty of asking you to print a passage from it, in parallel column, with a passage from Jeff. Davis' recent message. It will show how singularly great minds think alike, even under the most adverse circumstances.
From a speech by Mr. Terry delivered on May 30, 1864, in Debates in the Convention for the Revision and Amendment of the Constitution of Louisiana. Assembled at Liberty Hall, New Orleans, April 6, 1864 (1864):
Mr. Benjamin was in the convention of 1852, and by reference to the proceedings of that convention it will be seen that he used precisely the same argument in favor of an appointive system, and in opposition to an elective one, as Mr. Cutler does. In fact, if Mr. Cutler does not borrow his speech from J. P. Benjamin, he furnishes an apt illustration of the popular refrain, "great minds think alike."
From "Our New York Letter," in the Charleston [South Carolina] Daily News (December 13, 1866):
The telegraph informs us that "the immortal J. N." has had an interview with Jefferson Davis, and that Mrs. Davis, mistaking (!) him for a lunatic, dispatched a messenger to the Surgeon of the post. J. N., the immortal, is the long-haired individual who held forth in your city, about a year ago, in front of the Charleston Hotel, on the questions of the day. You will remember that he honored your sanctum by a call, and that whilst there he surprised your correspondent, who happened to be present,by touching his forehead most significantly (his own forehead, I mean), and asking whether I thought that said head was fixed on in a proper manner. I replied that it seemed to be so, but that I would suggest that its general appearance would be much improved by the application of a scissors, a comb and a brush. Great minds think alike. No wonder, then, that Mrs. Davis' fears were excited.
From "Colonel Younger on Short-horns," in the [San Francisco, California] Pacific Rural Press (July 4,1874):
EDITORS PRESS:—Great minds think alike, said I to myself, as I read the first four paragraphs under the above heading in your last issue, and recalled to mind Dr. A. P. Stevenson's address on "Short-horns and their Points," before the Indiana State Short-horn Convention, at Indianapolis, May 21st, 1872.
From "A Story of Aggravation," in the Perrysburg [Ohio] Journal (December 25, 1874):
Sixth week.—The day before Christmas. Returned, the prose version of "The Cow Jumped Over the Moon," with thanks. "The editor would have used it, but he had accepted an article before receiving it, on precisely the same subject, which would appear in the present number." Singular, and yet more singular that the article on the same subject proved to be written by the editor in person. But Mamma Mullein had for her consolation the adage that great minds think alike.
A number of the preceding instances of the expression seem to contain a satirical edge, but an instance from 1877 makes the lighthearted usage explicit. From the Rev. Professor Chapman, "Our Obligations to Greek Thought," originally read on November 8, 1877, reprinted in Journal of the Plymouth Institution (1877):
In estimating the connection between modern and ancient conclusions, it behoves us to avoid the fallacy of confounding coincidences with derivation; and we should be careful to abstain from the delusive habit of importing into the terms and propositions of one age the ideas of another. "Great minds think alike," as we say in pleasantry; and we are apt to see our theories everywhere.
The remark "great minds often think alike on the same occasions" appears in a 1728 volume of observations by a French priest, rendered into English with additional adornments by an English translator and writer. The shortened expression "great minds think alike" begins popping up in Google Books and Elephind search results in 1849, and becomes firmly established as an aphorism in the United States by the middle 1860s. Use of the expression in an ironic or playful sense seems to have occurred fairly early in its emergence as a proverb—and certainly by the middle 1870s.