This is a traditional toughening exercise in some martial arts, sometimes referred to in Japanese martial arts as Jari Bako. The long and short of it is that it works by traumatizing your hands, causing them to scar up to become tougher. Side effects may include cosmetic damage, loss of sensitivity, and loss of mobility in your fingers.
Steve Weigand added in the comments:
I’d add that practitioners of this kind of toughening exercise never attain the abilities that are promised to them, the biggest one being that you will be able to pierce the flesh of your opponent like a dagger. That stuff is for the movies. This is one practice that should be thrown in the dust bin of flawed martial theories. I trained this way in my teen years, btw. It will rip apart your nail cuticles and can leave you with arthritis in your fingers. Adding herbal jows is pretty useless.