The phrase like lightning, and its variants like greased lightning and as quick as greased lightning, denote extreme quickness of movement.
The earliest known occurrence of the image is from The Iliad of Homer (London, 1718), in which the English poet Alexander Pope (1688-1744) tells how Jove, “the Sire of Gods”,
The Grecian Ardour quench’d in deep Despair;
But lifts to Glory Troy’s prevailing Bands,
Swells all their Hearts, and strengthens all their Hands.
On Ida’s Top he waits with longing Eyes,
To view the Navy blazing to the Skies;
Then, nor till then, the Scale of War shall turn,
The Trojans fly, and conquer’d Ilion burn.
These Fates revolv’d in his almighty Mind,
He raises Hector to the Work design’d,
Bids him with more than mortal Fury glow,
And drives him, like a Light’ning, on the Foe.
(The spelling light’ning in this translation of the Iliad shows that the current form lightning is historically a contracted form of lightening, from the verb lighten in the sense to flash lightning, and the suffix -ing denoting a verbal action.)
The phrase like lightning is first recorded in A journal of the Plague Year (London, 1722), by the English novelist and journalist Daniel Defoe (1660-1731):
Now upon this Notion spreading, (viz.) that the Distemper was not so catching as formerly, and that if it was catch’d, it was not so mortal, and seeing abundance of People who really fell sick, recover again daily; they took to such a precipitant Courage, and grew so entirely regardless of themselves, and of the Infection, that they made no more of the Plague than of an ordinary Fever, nor indeed so much; they not only went boldly into Company, with those who had Tumours and Carbuncles upon them, that were running, and consequently contagious, but eat and drank with them, nay into their Houses to visit them, and even, as I was told, into their very Chambers where they lay sick.
[…] As this Notion run like Lightning thro’ the City, and People Heads were possess’d with it, even as soon as the first great Decrease in the Bills [= death toll] appear’d, we found, that the two next Bills did not decrease in Proportion; the Reason I take to be the Peoples running so rashly into Danger, giving up all their former Cautions, and Care, and all the Shyness which they used to practise.
The variants with the adjective greased are of American-English origin; here, lightning is likened to a machine that a mechanic has lubricated in order to minimise the friction and make it run easily.
The earliest instance of greased lightning that I have found is from an article originally published in “the United States Norfolk Herald” and copied in several British newspapers in December 1832 and January 1833—for example in The Courier (London) of Wednesday 26th December 1832:
American Militia Muster.—“’Tention the hull! Shoulder! As you were!”—“I say, Capting [= Captain], Mike’s priming his firelock with brandy.”—“Why, Deacon Michael Bigelow, aint you ashamed to do sitch a thing arter the temperance paper? I’ll report you to the Court Martial. You, without bagnets [= bayonets] on your corn-stalks, stand back in the rear ranks—trail arms.” “Capting, why the dickens don’t you put the ranks farther apart? That are chap’s bagnet has stuck into Jem’s trousers, and I rather guess he won’t sit down as slick as he used to do.” “I say, Mister, don’t blow your backer smoke my face.” “Why, darn it, how could I help it? This here fellor, shoulderin’ his firelock, struck his bagnet strate through the rim of my beaver, and I rather guess any on ye would jerk your head a little on one side, smoke or no smoke. Mister, hand me down my hat.” “Can’t do it—wait till the Capting tells us to order arms; won’t bring down my firelock without orders if your head was on the top of it.” “That’s right, Joe, rale soger, I tell ye; only arter this shoulder your firelock perpendicular.” “John, you’ve got a firelock—what made you bring your numbrel [= umbrella]?”—“Why, Capting, the wind was due east, and I heard the turkeys screeching, so I knew we’d have a shower.” “Tom, what are you bawlin about?”—“Why, Capting, Jim Lummis smashed my toe with the butt of his gun, and I rather guess its a 36-pounder, for its tarnashun [= tarnation] heavy.” “Jim Lummis, just have the purliteness [= politeness] to take your gun off Tom’s toe; and look out how you smash arter this.” “Capting, I say, here’s an engagement on the right flank.” “You don’t say so, Leftenint [= Lieutenant]—what is it?” “Why, Parks Lummis and George King fighting like blazes.” “We’ll make a ring after parade, and see fair play, only tell them to wait till we’re done sogerin [= soldiering, i.e. drilling?].” “Capting, I say, its arter sundown, and I rather guess I need’nt stay any longer according to law. “Well, I’m agreed. Now get into a srate line as quick as greased lightning. Right face, dismiss.”