They are used to help hold bones etc. while eating. Some dogs with larger dewclaws use them for better balance when running. Some dogs do not use them at all. It depends on the size of the dog and breed.
Dew-claws on a dog are a vesitigial toe. Some breed standards actually require there be a minimum of two dew-claws on each back leg. i.e. Great Pyrenees. While some breeds it is only a single it is...
Do not pull or cut unless you can see that it is almost not attached. It is preferable to bandage the part of the leg for giving time to it falls by itself.