I found a very large caterpillar while gardening today; it was buried in dirt, and I almost killed it. It looks like a moth caterpillar. Many caterpillars burrow into soil to pupate, and others fasten themselves to a plant. They do this since they require a safe environment when they undergo transformation. Some caterpillars also spin a cocoon and pupate inside it for extra protection.
As the moth caterpillar began wiggling itself about in the heat of the sun, I lifted it in my shovel and placed it under a rock nearby. Later I covered it with a couple handfuls of dirt, I hope that will help somehow.