Today's phrase comes from the literal rubbing of a cat. Apparently there is a way to do it and way not to do it. And when you do it the wrong way apparently you know. (source)
Today we use it to indicate that someone has upset or irritated us...greatly.