Cats scratch to protect themselves from threats and to mark their territories. Scratching is also a cat's way of whittling down its claws, since the claws are continuously growing. Cats also scratch just to stretch their muscles.
Scratching plays an important part in the world of the cat. Cats use their claws to explore their environments, and naturally their claws come into play while doing this. When cats scratch, their claws release scent pheromones. These invisible chemicals are used by the cat to mark its particular territory and alert other cats in the area that the territory is already claimed.