Im not sure if this has been answered before but its something I've always wondered. It seems like it would be quite confusing to touch something then randomly get a shock and not have a good answer to what happened.
There is always more to be said, but /u/hillsonghoods did an excellent job addressing it previously here, which I'd recommend you give a look to as a starting point!