Dogs dig for various reasons: 1) They are bored as already mentioned. Dirt is fun. Dogs dig, the dirt goes flying. They dig faster, more dirt goes flying. The fresh soil smells good to a dog. They roll in it, they taste it. They are burning off energy. It is our job as their owners to give them lots to do to engage their minds such as interactive toys, games of search, or increase the amount of training sessions per day. Bored dogs are usually under-exercised. Go out in the yard and play fetch, invite a 4 footed friend over so your dog can play, rotate his toys or go on a hike with him.
2) Dogs also dig if they are chasing prey such as moles, chipmunks or bugs...yes they get entertained by bugs. Terriers seem more apt to dig for critters but any dog can.
Dogs will dig in snow to follow moles that for some reason decided to venture out on a warm day.
3) Dogs will dig if they are looking for a means to escape. Their digging is usually around gates and fence lines. If your dog is whining, pacing, panting, and/or digging around these areas he could be stressed about something. He may never have learned to be left alone, he may be suffering from separation distress. Consult a reward-based trainer who uses only humane methods to help you help your dog.
4) Dogs dig to hide items for later use. This is a trait hard wired in some dogs, it is a survival behavior retained from their ancestors. It can be a bone, or it can be a toy, or several toys. Freshly cleaned toys are quickly rolled in the dirt, it seems the more dirt on the toys the better. That is why we have inside toys, and toys that are just for outside.
5) Dogs also dig to keep cool!! Our dogs are inside in AC in the very hot weather. They are in shaded areas when outside.
They are given hammocks to lay on.

A cottage to go into, a kiddy pool to play in, and access to a wooded area ....to dig in.
Dogs that are now gone, began to dig near the roots of a tree that was uprooted during a wind storm over 20 years ago.
Melissa has decided to join in.
She gathers her toys and places them in and around the 'fort'. Sometimes she lies in the hole with the toys. The soil is cooler then the air temp, it must feel good to her. It is her spot to dig, we have never had a dog dig in our lawn or gardens. She is not digging due to boredom, looking for little animals or looking for an escape route. She will dig after a long hike and hours of splashing and swimming. I believe she is digging to keep cool and have a place to watch all that goes on around her. She digs to hide her toys.
And best of all, despite the many dog hammocks in the yard, a hole is a good place to take a nap........my silly muddy nose girl.