The phrase to scare (or beat, knock, etc.) the (living) daylights out of somebody means to scare (or beat, knock, etc.) somebody with great intensity or severity.
Here, the adjective living is used as an intensifier, and daylights is an 18th-century slang term for eyes chiefly used in contexts of physical violence or threats.
The earliest known instance of daylights used in this sense is from The Flash Dialogue between Moll King and Old Gentleman Harry, as it appeared in The Life and Character of Moll King: Late Mistress of King’s Coffee-house in Covent-Garden, who departed this Life at her Country-House at Hampstead, on Thursday the 17th of September, 1747 (London, 1747?)—this dialogue had been published about fifteen years earlier in a lost pamphlet, The Humours of the Flashy Boys at Moll King’s:
Harry. I’ll derrick, my Blood, if I tout my Mort; I’ll tip her a Snitch about the Peeps and Nasous, I shall see my jolly old Codger by the Tinney-side, I suppose with his Day-Lights dim, and his Trotters shivering under him. […]
This was Part of the Cant that the Gentry of King’s College were mighty fond of; and which too many People now scandalously affect to practice; but by Persons of Modesty and Understanding, those that are so ridiculous as to use it, are looked upon not to be very well bred.
In the same book, Key to the Flash Dialogue contains the following explanations:
This gave rise to the phrase to darken somebody’s daylights, meaning to give somebody black eyes, and more generally to knock somebody senseless; this phrase is first recorded in Amelia (London, 1752), by the English novelist Henry Fielding (1707-54):
‘I don’t use to be so treated—If the Lady says such another Word to me, d—n me, I’ll darken her Daylights.’
The phrase to [verb] the daylights out of somebody was preceded by to [verb] somebody’s daylights out, first recorded in Jokeby, a burlesque on Rokeby, a poem, in six cantos, by an amateur of fashion (London, 1813), by the English banker and author John Roby (1793-1850):
Much stronger men I have knock’d down,
In darker places of the town;
Might I not dash thy day-lights out,
Ere thou could’st turn thyself about?
The earliest instance of to [verb] the daylights out of somebody that I have found is from The Weekly Waterford Chronicle (Waterford, Waterford County, Ireland) of Saturday 23rd May 1840:
Before the Right Worshipful the Mayor, and Alderman Alcock.
Bridget and Ellen Quinn v. Thomas Power, for assault at Ballytruckle, on the 19th of May.
Bridget Quinn sworn.
Alderman Alcock—Do you know Thomas Power?
Bridget Quinn—I do, your raverince (a laugh).
The plaintiff went on in a lugubrious tone of voice to complain of the dire mishaps caused to her by the defendant, who struck her terribly, and knocked the sinses out of her; in truth of which, your Worship, (said the witness to Mr. Walter Phelan, who cross-examined her), you may view my countenance, and see how transmogrified it is—(laughter). And more betokens, here’s my daughter’s little frock, that thought to save me, all torn in pieces by the same vagrant (more laughter).
Mr. Phelan said that the plaintiff in this case was the aggressor; the defendant was passing by when she threw a stone at him that cut him in the head, the marks of which were visible.
Plaintiff (wringing her hands)—Oh! you would swear the daylights out of a body (laughter).
The magistrates dismissed the case, and told the parties to be better neighbours in future.
The earliest instance of the living daylights out of that I have found is from a paragraph about a musician named Mr. Ketten, published in The Daily American (Nashville, Tennessee) of Sunday 25th January 1880:
He hammers his tunes out with vigor, but has an unpleasant way of sitting about two yards from his piano, as though afraid it would claw back when he treads on its tail. He has also a queer habit of drifting up to the windward and belting the living daylights out of the loud end of the instrument.