It is an expression that appears in Don Quixote, and describes an exaggerated situation, of anger, of fear, of astonishment, since the teeth do not sweat.
Sweating your teeth means exhausting yourself in a titanic or excessive effort to solve a problem or task.