Robert Herrick's "To the Virgins, to Make Much of Time," addresses the theme of "carpe diem," or "seize the day." In other words, the author addresses young virgins, urging them to live for today for tomorrow is uncertain, or suggesting that they live "life to the fullest."
Poems of this type, popular with Cavalier poets of the 18th Century, would often argue to this end, encouraging young women to surrender their virginity (generally to the author), for life was uncertain in the present state, and youth and beauty faded quickly.
The line you reference is found in the second stanza, lines 5-8. Within the context of the stanza, we find several literary devices (elements):
The glorious Lamp of Heaven, the Sun,
The higher he’s a getting;
The sooner will his Race be run,
And neerer he’s to Setting.
The "Sun" is personified here. Personification gives human characteristics to non-human things and is a form of figurative language, or is also referred to as a figure of speech. Its definition is...
...a figure of speech in which abstractions, animals, ideas, and inanimate objects are endowed with human form, character, traits, or sensibilities.
Here, the Sun is described as running "his Race," referring to the sun's passage through the sky throughout the daylight hours. A person runs: the sun cannot.
The literary element most important to the comparison between the "Lamp of Heaven" and the "Sun" is the metaphor. (It also is an example of figurative language.) Basically, a metaphor compares two dissimilar things that share the same characteristics, presented as if they were the same, without using "like" or "as." A metaphor is defined as...
...a figure of speech in which a word or phrase is applied to a person, idea, or object to which it is not literally applicable. It is an implied analogy or unstated comparison which imaginatively identifies one thing with another.
In the poem, the "Sun" is being compared to a lamp. While these two things are very different, both emit light that illuminates: the lamp may illuminate a room, a hall or even a pathway. On a much grander scale, the sun illuminates the face of the earth as it passes overhead. Both are also hot, and have the capacity to warm or burn. Neither the lamp or sun is the same, but each shares the same characteristics.
In Robert Herrick's "To the Virgins, to Make Much of Time," the metaphor of the sun being likened to a lamp also serves to further the theme of carpe diem which is the main idea of this poem. For, like a lamp, the sun loses its light after the day is done, and does not arise until the next day when time has passed. So, the idea of taking advantage of opportunities while it is light and before darkness sets in suggests the theme of making the most of time. The metaphor of the sun's being a lamp of heaven serves well to develop the controlling metaphor of Herrick's poem that time is fleeting.
It's a metaphor. Notice how the author is comparing the sun to the "glorious lamp of heaven" without using the word "like" or "as." Had he chosen to use like or as, that would make the ;iterary device into a simile. Instead, he chhoses the direct route, simply naming something as something else and allowing the readers to put the clues together on their own.
Metaphors are commonly used in poems that are both canonized and contemporary; a look at works by poets ranging from Frost to Collins will prove this assertion to be true. Metaphors are one of the most widely used poetic devices.