getting on ones nerves

Where does the expression “getting on my nerves” come from?

You have a cavity, and get something on that exposed nerve. Now, apply that same level of DEEP unhappiness to another human being. Makes sense to me.

Cartooniverse

Is that the origin of the term or are you speculating?