Inversions after negative adverbials
There are some words and phrases that function as adverbials that sometimes need an inversion. Look at these two sentences.
Bob rarely speaks to himself.
Rarely does Bob speak to himself.
The adverb here is "rarely". If it comes after the subject, there is no inversion (as in the first sentence), but if it comes before the subject, we need an inversion. The word order is inverted and in the case of the sentence about Bob we use the auxiliary verb "does" in the same way we do in questions (although this isn't a question).
The sentence with the inversion sounds more formal or more literary, and sentences like this are less common in ordinary conversation.
Here are some examples with other phrases used in the same way.
Seldom does Bob get invited to parties. (seldom = rarely)
Never have we seen such a breathtaking view.