I have seen films in which a martial artist thrusts his fingers into hot sand.
What is the name of this exercise and what are its benefits?
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.
Famous judoka Masahiko Kimura adopted this practice (historically used in striking arts) ostensibly with the intention of "strengthening" his hands and fingers (desensitizing them to pain), to allow him to grip his opponents with more force for longer:
I had thought that those who are trained in judo have strong finger tips, elbow, wrists, and fists. But, when I actually struck the Makiwara, my finger tips, elbow, wrists, and fists all hurt numbingly. Such weak finger tips, elbow, wrists, and fists are useless in pulling the opponent or controlling the opponent using elbows or wrists. I therefore slammed these weak parts onto Makiwara and strengthened them in preparation for bouts. I struck Makiwara with knife hand, backhand, and thrust 4 fingers into a sand box. I did this 1000 times a day. In this way, I developed steel-like strong hands. Later on, I got interested in karate, and learned Shorinji-ryu (Note: today's Shotokan karate) under the guidance of Master Funakoshi for a little over 2 years.
The “piercing the flesh of your opponents” thing only works if you keep your nails just short enough. The nails break the skin and the hand does the rest. Also you want to work with loose sand and let it do its work gradually. The ones who mess up their hands are the ones who don’t understand that this is a thing that is developed over time and that you shouldn’t over do it.