Originally, in Greek and Roman poetry, the elegy, which is now defined as a poem that laments the death of a friend or a beloved public person, referred just to the meter of a poem (elegiac distiches) and had nothing to do with content. In English literature, following the Greco-Roman model, poets like John Donne used elegy to mean a lyrical poem that could take love and satire as subjects.
With Spenser's pastoral elegies in The Shepheardes Calendar in 1579, in which he often laments the untimely death of a shepherd, and Milton's Lycidas in 1637, in which Milton laments the death of a poet named Edward King who was a promising poet but whose life was cut very short by drowning, the elegy began to take on the form in which it was to last in English literature, a lament on often untimely death or a lament for the transience of life.
Although the elegy originally was centered on death and dying, it has become over time the form of any poem whose subject is a solemn meditation on death, the struggles in life, war--any momentous subject that the poet discusses in somber, reflective tones, usually with some degree of sorrow and resignation.
The most well-known elegy in English literature is Thomas Gray's An Elegy Written in a Country Church Yard (1751) in which Gray, still lamenting the death of his friend Richard West (first discussed in a sonnet in 1742, also elegiac), is an elegy to man's transient life rather than for a specific individual but follows the elegiac conventions of detailed nature observation, creating a pastoral scene, and a solemn, reflective tone throughout. Other examples of elegies include Tennyson's In Memoriam, Yeats's The Wild Swans at Coole, and several of Emily Dickinson's poems, for example, Because I could not stop for Death.