The dewclaw is attached to the fifth digit of the forepaws of cats. Normally this digit is high up and away from the other four. For some domestic cats this rudimentary digit is actually a solid looking thumb.
The dewclaw is still useful to a cat because although the fifth toe is short and somewhat rudimentary, the claw is normal is size. You’ll see domestic cats use it to hang on to things including prey. Although it can get entangled in household items sometimes.
It seems that the normal number of toes for animal with four legs and backbones is five. The domestic cat has five on the front and four on the back. It is unclear to me why evolution created this state of affairs. Although it may help the cat to run faster.
This could be true and the reason why the forepaws have five toes (you could say 4.5 because the dewclaw is half a toe) is because the forepaws have to grab prey and other objects. The extra toe helps. Four paws on the hind legs is a nice compromise between the need for grip on the ground and minimal contact much like the horse which has one digit remaining (the middle digit).
Dogs have dewclaws which are sometimes surgically removed when the animal is young.
Why is the dewclaw out of position and away from the other four toes? Well I can’t find the answer so I’ll decide myself. I have already mentioned that the hind leg paws have four toes to help the cat run faster. It seems that the forepaws have evolved along similar lines and with the four toes touching the ground while the fifth is out of the way about an inch higher. It does not touch the ground. Perhaps in a few thousand years the dewclaw will disappear altogether.
Why is it called the dewclaw? I can’t find a clean answer on this either but it is said the dewclaw brushes the dew off the ground as it is high up. This may be the reason.
P.S. The dewclaw can be missed when checking if the claws need trimming. This can lead to a ingrowing claw, causing pain and discomfort especially in elderly cats. There is a very popular page on this site showing declaw regrowth of the dewclaw. It is horrendous. Claw regrowth is an issue after the declawing operation because bits of claw can remain which continues to grow under the skin.
Please search using the search box at the top of the site. You are bound to find what you are looking for.