c. 1400, scracchen, transitive, "mark or wound slightly on the surface by a scraping or tearing action with something rough, sharp, or pointed," probably a fusion of Middle English scratten and crachen, both meaning "to scratch," both of uncertain origin. Also compare scr-. Related: Scratched; scratching.
The meaning "relieve skin irritation by a scraping motion with the nails or claws or a scratcher" is by 1520s. The billiards sense of "hit the cue ball into a pocket" is recorded by 1909 (also, originally, itch), though earlier it meant "a lucky shot" (1850). The meaning "to withdraw (a horse) from a race" is 1865, from notion of scratching its name off a list of competitors; the phrase was used in a non-sporting sense of "cancel a plan, etc." by 1680s.
To scratch the surface "make only slight progress in penetrating or understanding" is from 1882. To scratch (one's) head as a gesture of perplexity is recorded from 1712. The plastering scratch-coat, roughened by scratching before it sets, is by 1891.