The phrase salad days denotes a period of youth and inexperience.
It was coined by the English poet and playwright William Shakespeare (1564-1616) in The Tragedie of Anthonie, and Cleopatra (Folio 1, 1623); in Act 1, scene 5, Cleopatra, now in love with Mark Antony, is reflecting with her attendant Charmian on her youthful affair with Julius Caesar:
My Sallad dayes,
When I was greene in iudgement, cold in blood.
A salad uses vegetables which are raw (green and cold), and it is this characteristic that provides the metaphorical sense.
However, it seems that when Cleopatra is reflecting on her youth, green and cold not only refer to salad days but also have contradictory meanings revealing her personality. In Shakespeare’s time, green, denoting the colour of a young and tender plant, had already, when applied to a person, acquired the figurative meanings young, youthful and immature, raw, inexperienced. So, when Cleopatra remembers that she was “green in judgement”, she might mean that she was naive. But when she says that she was “cold in blood”, she might refer to her cold-bloodedness: her affair with Julius Caesar might have been motivated not by passion for him but by the political need for a strong military ally in her claim to the throne.
It seems that the allusive uses of salad days do not appear until in the early 19th century. In the earliest occurrence that I have found, from a story published in The Camden Journal (Camden, South Carolina) of 20th August 1836, the phrase is misattributed to the English poet, critic and philosopher Samuel Taylor Coleridge (1772-1834):
He made a Mrs. Fitzgig of Miss Seraphina Serena Pump, taking her for a femenine [sic] woman, when the “lurking devil in her eye” [see note] might have told him that she was a masculine woman—the greatest mistake of the whole troop of blunders. As to the last, however, Fitzgig was a little to blame. He had seen manifestations of Seraphina Serena Pump’s energies; for he was present when she took a cat by the tail which had scratched her, whirled it two or three times round her head, and slung it, whizzing and scratching, through the window into the street; and again he saw her bung her father’s eye with an egg at breakfast because he would not promise to buy her a new bonet [sic], with other little affairs of the sort; but Fitzgig, like ourselves, in our “salad days,” as Coleridge calls the time, when we fall in love with bright eyes and such matters, liked a lady none the worse for a little sprinkling of the “old un” in her composition.
Note: The phrase a lurking devil in her eye had been used, in particular, by the British playwright John Tobin (1770-1804) in his highly successful comedy The Honey Moon (London, 1805); it may ultimately be an allusion to, or a recollection of, the opening lines of An Extempore Thought on Flattery, included in Poems on Several Occasions (London, 1720), by the English poet, playwright and songwriter Henry Carey (1687-1743):
Flattery’s a base, unmanly, coward Vice,
A lurking Devil in a fair Disguise.