Domesticated dogs that scratch the floor before lying down do so from an instinct to scratch to create a softer or safer resting place. In the wild, dogs scratch the ground to create comfortable, temperature controlled sleeping spots, and domesticated dogs instinctively mimic this behavior when lying on the floor or furniture.
A dog that scratches the floor is attempting to dig a hole. Wild dogs depend on holes to keep them safe and protected from heat or cold temperatures. This instinct does not leave a dog just because it's an indoor pet. Dogs may also circle the area where they scratch before lying down.