Dogs enjoy rolling around in dirt or rubbish because the odour masks their own smell. This was useful in the wild when hunting prey and trying to avoid being hunted themselves.