Rubber, being an insulator, prevents the electric current from passing through it. Thus, these gloves protect you from shock.