What is the grammatical function of "never"?

Never is a negative time adverb meaning 'not at any time', but no/not (variant combining forms) is a much more versatile and important chunk of English. Not is just one of the forms it uses when it's a separate word, instead of existing combined in a compound or contraction.

It's the basic Negation marker in English. So it can be adjective and adverb, but mostly it's fused into phrases and contractions, of which never is one. Never is a contraction of no/not + ever, just like other contractions of no/not:

  • never = not ever
  • none = not one
  • neither = not either
  • nor = not or
  • no way
  • nowhere
  • nobody
  • no one
  • nothing

There are corresponding contractions with the Negative Polarity Item any, like:

  • anyway
  • anywhere
  • anybody
  • anyone
  • anything

which are Negative Polarity Items, like ever. Ever means what *anywhen would mean, if there were an English word *anywhen that was as commonly used as anywhere; in the same way, both of them means what *all two of them would mean, if that phrase weren't ungrammatical.

More important, as a Negative Polarity Item, ever can only occur within the scope of a Negative Trigger (or, as in never, bonded morphologically to its trigger).

Thus, ever is fine in these 3 sentences, with Negative Triggers (has)n't, few, and doubt,

  • He hasn't ever seen it. ~ Few people have ever seen it. ~ I doubt he's ever seen it.

but it makes the corresponding affirmative sentences ungrammatical, though they're OK without ever:

  • *He has ever seen it. ~ *A few people have ever seen it. ~ *I think he's ever seen it.

The exact label/category that you ascribe to a word depends on the purpose of your analysis. Usually the purpose of that analysis to assign words with similar broad features to the same category.

From that point of view, when used for "sentential" negation, never and not differ in an important way: "not" in reality occupies a 'special' position in the sentence and has special morphological behaviour, whereas "never" is much closer in its behaviour to a "normal" adverb. Consider:

He typically comes at 6 o'clock.

He never comes at 6 o'clock.

*He not comes at 6 o'clock.

So as a starting point, a crude categorisation would be to say that "never", but not "not", is an adverb.

One further subcategorisation you could make is to say that "never" is specifically a type of adverb that is associated "close to the verb phrase" syntactically. In other words, it can't typically be an adjunct to broader units (such as the whole sentence), unlike other adverbs:

He will undoubtedly/never be late.

He undoubtedly/never will be late.

BUT: Undoubtedly/*never, he will be late.

So one term for this type of adverb is to call it a "VP-adverb", in other words, an adverb that is associated with the verb phrase.