"Lycidas" is an elegy in that it is a poem that laments its subject's death. And it's a pastoral elegy in that it's set among an idealized rural landscape full of nymphs, muses, and sundry other figures from ancient Greek mythology.
In writing "Lycidas," Milton follows the conventions of pastoral elegy by idealizing his subject, the recently deceased poet Edward King. With the expert stroke of his quill, Milton transforms his friend and Cambridge contemporary into the noble figure of Lycidas the shepherd, taking his cue from ancient poets such as Virgil, whose own Lycidas was also a gifted shepherd-poet.
As a shepherd, Lycidas lives and works in the countryside, putting him in close contact with the natural world, far away from the hubbub of life in the town. As a poet, he's undoubtedly talented, but due to his life being tragically cut short, he will never get a chance to fulfill his promise. It has fallen to his friend, the infinitely more talented Milton, to use his superior poetic gifts to keep the flame of Lycidas's memory alive.
Once again drawing from antiquity, Milton avers that fame is eternal, not mortal. In immortalizing the name of his dear departed friend, Milton is hoping to ensure that King's fame as a poet—or, to be more specific, a potential poet—lives on long after he himself has passed away.
Indeed, one might argue that the chief purpose of pastoral elegy in general is to ensure that the subject is never truly forgotten by posterity. Placing the elegized subject in an idealized rural setting helps to achieve this goal as a pastoral landscape is recognizably earthly while at the same time enjoying a timeless quality not shared by an urban environment.