I believe it originates from eary boxing matches, possibly even illegal fights, where two 'scratches' or lines marked in the dirt represented the starting point for each fighter. As they were ready, they 'came up to scratch' ready to start. I think I have read this somewhere, if I'm wrong, the bottomless pit of knowledge possessed by my learned friend QM will be investigated, and a more suitable answer supplied shortly.
That is indeed it Andy. The more often used phrase "not up to scratch" applied when the boxer couldn't stand up to fight any longer and wasn't able to get to his mark to begin fighting again and he literally wasn't "up to scratch"
Scratch in golf has been taken from foot races. A scratch in the dirt was made as the start line. The best runners started there. In a handicap race the weaker runners started further up the track at other points. They were given so many yards 'start' ; the more yards given the weaker they were taken to be; the idea was that all the runners would finish level and so make the race more exciting and even (and, in gambling, attract bets on every runner.) This is the principal of all handicaps. In golf the scratch player is the best; the weaker ones are given so many shots 'start' over the best one so that they can compete equally with him or her..