It's thought that the pinching started in the early 1700s, about the time that awareness of St. Patrick's as a holiday came to the fore, too, in Boston, in the Massachusetts colony. They thought if you wore green, it made you invisible to the Leprechauns, which was good because they would pinch anyone they could see. So the pinching is to warn and remind you about the Leprechauns.
Pinching those not wearing green on St. Patrick's Day is an American tradition, having really nothing to do with Ireland or St. Patrick Wrong. I have lived in Ireland. The truth is, Irish people think Americans are crazy. St. Patrick's Day is not even remotely celebrated over there as heavily as it is in the US.