Worms which are seen crawling in dead matter are in fact maggots or the larvae of flies. When a human being or an animal dies, its body starts emitting foul smell due to putrefaction of tissues.
Flies are soon attracted to the smell which start showing up within 2-3 hours of death. By 12 hours or so, the body will be more or less engulfed with flies. Son after one can see the body covered by tiny white dots which are nothing but the eggs laid by flies.
How soon the eggs will hatch, depends on the type of flies in question but within few hours, maggots can be seen crawling beneath the flesh.
When the maggots hatch the first thing they do is burrow under the skin, leaving tiny holes, like pock marks all over the body. The maggots burrow down deep and eat all of the inner flesh.
There are thousands of maggots which eat away entire flesh in few hours. Soon after the flesh is finished, they start appearing on the skin — what we see as worms. One can control the appearing of maggots by spraying strong disinfectant all over the body or by embalming. Embalming is the process by which a dead body can be preserved temporarily for some time.
In this process a liquid, generally, formaldehyde or/and ethanol is injected in to the body through the arteries. In ancient times Egyptians used to preserve dead bodies by mummifying them. Mummifying (see picture above) is different from embalming where body fluid and soft tissues were taken out and the cavities thus formed were filled up by disinfected material.