According to the ASPCA, dogs scratch at carpets because they are instinctively driven to dig. Dogs dig in the wild to make comfortable sleeping places, to entertain themselves, to bury items they want to save for later and to hunt.
Puppies are more likely to scratch at the carpet than older dogs, and dog breeds, such as terriers, that are bred for hunting burrowing animals scratch far more often than other breeds. One way to reduce unwanted digging and scratching behaviors is to provide a dog with plenty of safe outlets for its energy. Long walks and interactive play sessions in the yard keep dogs entertained and have them ready to rest when playtime is over.