Set teeth on edge
The current "origin" is shown from Shakespeare. I see a similar phrase in Bible KJV Jeremiah 31:29 "In those days they shall say no more, The fathers have eaten a sour grape, and the children's teeth are set on edge."
Joe
Also Ezekiel 18:2.
I would imagine it was a saying common in the 1600s.