[A humble request: If you can, please donate to help me carry on tracing word histories. Thank you.]
The expression gallows-humour designates grim and ironical humour.
The noun gallows designates an upright frame with a crossbeam and a rope, for hanging condemned persons, and the expression gallows-humour alludes to the practice of public executions—as illustrated, below, by quotation 1.
The earliest occurrences of the expression gallows-humour that I have found are as follows, in chronological order:
—Note: With one exception (quotation 1), in all the texts, the expression gallows-humour is a loan translation from the German noun Galgenhumor, composed of Galgen (i.e., gallows) and of Humor (i.e., humour):
1-: From A strange scene at an Irish execution one hundred and twenty-five years ago, published in The Bristol Times, and Felix Farley’s Bristol Journal (Bristol, England) of Saturday 3rd November 1860 [page 6, column 2]:
The particular scene […] with which I have headed this paper, took place in the month of August, in the year 1735, in front of the gaol of Armagh, in the north of Ireland and, as a specimen of grotesque, awfully grim and profane (shall I call it?) humour, I fancy has never yet been surpassed […].
I find the account in the “Monthly Intelligencer” for September, 1735, into which it was apparently copied from an Irish MS. Newsletter, and I give it nearly, though not exactly, in the words of the original narrative; for the style, in a few passages, is so obscure as to be hardly intelligible without a little alteration.
The convict’s name was Mackin, and he was sentenced to death for cow-stealing […].
[…]
Upon reaching the gallows, he mounted the ladder with an easy step […]. Here voices arose from the crowd, observations being made from various quarters, as though the owners of lost property wished to put questions to him. One of the spectators cried out, “Pray, Mr. Mackin, do you know anything of my mare?”
“Suppose I did,” replied Mackin, “and will tell you, will you pay for one mass for my soul?”
“I will,” says the man in front of the gallows, suiting his promise with an oath, “I will pay for seven.”
“Promise me again,” says Mackin; the other did. “Why then,” said the hardened convict, bursting out laughing, “I know nothing at all of your mare.” This stroke of gallows humour caused, we are told, great amusement amongst the crowd.
2-: From The Times (London, England) of Wednesday 12th October 1870 [page 6, column 3]:
—The context is the siege of Paris (from 19th September 1870 to 28th January 1871), during the Franco-Prussian War (from 19th July 1870 to 28th January 1871):
INCIDENTS OF THE WAR.
THE GERMANS AT ST. CLOUD.Herr Wachenhusen, writing to the Cologne Gazette from St. Cloud on the 29th, says:—
“One day is much like another here. On our side the most perfect silence, according to orders; on the French side the greatest animation. They dig and scrape until the blood gushes from their fingers, and of an evening they sing before our eyes their cancan and their ‘Marseillaise,’ and other pretty songs, leap and shout half the night, until we are tired of it, and are as merry as if the world had never treated them better than now. I believe the Corps Francs and other volunteers have already plundered half the suburbs, and have taken to the second-hand dealers all the stolen articles that were vendible; they have therefore had a glorious time of it. The mob amuses itself, and the heroic youths, the gandins and petits crevés of the boulevards, give themselves up to a gallows humour, which will last until everything becomes topsy-turvy.”
3-: From a correspondence from Lille, in northern France, dated Saturday 12th November 1870, published in The Daily News (London, England) of Wednesday 16th November 1870 [page 5, column 6]:
—Here again, the context is the Franco-Prussian War:
Yesterday morning the folk of this once lively city knew not which corner of their sulky mouths to draw most deeply towards the earth’s centre of gravity. Even the gaiety of the recruits and their loose companions of the weaker sex in the cafés dansants, was barely loud enough to penetrate to the ear of the passenger on the sidewalk, and, if perchance one ventured a peep within, it was not the abandon of unmixed joy, but rather what the Germans call a “gallows humour,” that prevailed with the merriest couples. They seemed to be conscious—deeply so—of “dancing on a volcano.”
4-: From The Two Prisoners, translated “From the German of Professor W. H. Riehl, by Chapman Coleman”, published in Appleton’s Journal: A Magazine of General Literature (New York City, New York, USA) of July 1881 [chapter 1, page 37, column 1]—this story is set in Nördlingen, a town in Bavaria, Germany, in 1654:
Recourse was […] had to that severest of all touchstones—the torture. As confessions of guilt had so often been tortured out of people who insisted upon their innocence, why might not also a confession of innocence be tortured out of a man who insisted on his guilt?
The torture-chamber, however, only made matters worse, for when the thumb-screw was applied Muckenhuber stood sturdily by his old story, and when, in order to further arouse his conscience, the “Spanish boots” were laid on, he even proceeded to confess to a list of robberies, each of which in itself merited expiation on the gallows. The judge directing the torture had also intended administering to the accused a ride on the “sharp-backed donkey,” but, lest the obstinate fellow should then in addition confess to the crime of arson, oft repeated, it was decided to stop after the application of the first two degrees of the peine forte et dure; and the triumphant Jörg was led back to his prison. The high council was, however, more at a loss than ever, for, while the shrewder burghers began to realize that Jörg Muckenhuber was making game of the imperial city, such a case of gallows-humor was nevertheless quite unprecedented, and no one could imagine a reason why this unkempt vagabond should offer his neck to the noose and his limbs to the rack. This was entirely too much even for the most hardened of jokers.
The earliest occurrence that I have found of the German noun Galgenhumor in an English text is from Occasional Notes, published in The Pall Mall Gazette (London, England) of Tuesday 13th September 1892 [page 2, column 2]:
The workmen are now busy at the breaking down of the venerable university buildings in Leipzig, which belonged originally to the convent founded by the Dominicans in the year 1229. Together with the Paulineum, the library building, which dates from 1419, disappears the renowned “Karzer,” in which a series of famous men, including Lessing and Goethe, have in their time groaned as academical wrongdoers. The flowers of “Galgenhumor,” in prose and verse, which cover the ceiling and walls of the prison, are being very carefully transcribed, and will be preserved and published in a book. The regular course of work is not disturbed by the new building, as there are a number of university houses in Leipzig, in which interim lecture-rooms have been furnished.