It's all to do with the speed of air over the wing. If you need 100 knots of air flowing over the wing to get airborne and you've got 20 knots of headwind the aircraft only needs a groundspeed of 80 knots to get airborne i.e. less runway needed. Conversely if it had a 20 knot tailwind it would need to achieve a groundspeed of 120 knots to get airborne... longer take off run.