A relic, in religious context, is part of a dead saint's body, such as a finger bone or lock of hair, that is kept in a church and venerated, often in elaborate ceremonies on a day devoted to memory of the saint. In Donne's period, as now, this tradition of veneration of saints was practiced mainly by Roman Catholics and Eastern Orthodox Christians, and considered a form of idolatry by most Protestants. Donne himself was born a Roman Catholic and this poem in some ways reflects a tension between his Roman Catholicism and the Church of England.
As a love poem, "The Relic" is somewhat ambivalent. The poems suggests that if their bodies were dug up, the lock of the woman's hair would cause her to be thought of as a Mary Magdalene, a woman in the Bible normally interpreted as an example of a prostitute or woman of ill repute redeemed by Jesus who then forsakes her immoral sexual activities and becomes celibate. Thus the notion of love in the poem has a sense of something adulterous or forbidden, but capable of redemption.
The final stanza emphasizes this sense of the ultimate purity of the relationship, especially after death, despite whatever initial sense of scandal may have surrounded it.