If your dog is not receiving proper outlets for pent-up mental and physical energy, boredom can easily occur. Digging (along with other nuisance behaviors like barking and chewing) is one way that dogs release stored energy.
Some dogs may dig in an attempt to escape. This behavior is common among certain breeds, such as Siberian Huskies, that have a natural drive to wander. Additionally, female dogs in heat or intact males who sense nearby females are also more likely to try and escape an enclosure.
For dogs that are prone to overheating, digging a hole can help with heat regulation. The dirt inside a hole is naturally cooler than the air above the ground, and an overheating dog may use digging as a last resort.
Of course, dogs will dig in order to bury their treasures. Whether wanting to bury a bone, a favorite toy, or an unlucky squirrel, dogs have a natural drive to want to bury favorite items to save for later.
Some dogs have a natural drive to hunt animals underground. For instance, Jack Russell Terriers and Dachshunds are natural mole hunters. These dogs want to dig for the same reasons a Beagle wants to chase a rabbit. Additionally, dogs have a keen sense of smell and may be inclined to dig because they sense something interesting beneath the surface.