There are many reasons why dogs scratch the ground.
1. Dogs scratch the ground before lying down to sleep. After raising their feet to pee, dogs also scratches the ground. They are known to scratch the carpet within the home as they scratch the grass /ground outside.
2. Dogs also do this as a ritual before going to sleep so as to make the place comfortable, as also adjust to the ambient temperature.
3. They do it when they are bored or lonely.
4. They do it to hide things like bones so that some other animal does not steal the same away.
5. They scratch also to hide the faecal stuff and after urinating.
6. They do it to mark their territory, especially after urinating since the earth thrown about carries the smell of their urine.
7. Scratching is also done otherwise to mark the 'territory' since the dogs secrete from glands at their pads.