This has been extensively debunked by many medical sites, and Snopes. Here are some links:
While carrots are a good source of vitamin A (which is important for healthy eyesight, skin, growth, and resisting infection), eating them won't improve vision. The purported link between carrots and markedly acute vision is a matter of lore, not of science. And it's lore of the deliberately manufactured type. In World War II, Britain's air ministry spread the word that a diet of these vegetables helped pilots see Nazi bombers attacking at night. That was a lie intended to cover the real matter of what was underpinning the Royal Air Force's successes: Airborne Interception Radar, also known as AI. The secret new system pinpointed some enemy bombers before they reached the English Channel. British Intelligence didn't want the Germans to find out about the superior new technology helping protect the nation, so they created a rumor to afford a somewhat plausible-sounding explanation for the sudden increase in bombers being shot down. News stories began appearing in the British press about extraordinary personnel manning the defenses, including Flight Lieutenant John Cunningham, an RAF pilot dubbed "Cats Eyes" on the basis of his exceptional night vision that allowed him to spot his prey in the dark. Cunningham's abilities were chalked up to his love of carrots. Further stories claimed RAF pilots were being fed goodly amounts of this root vegetable to foster similar abilities.
The beneficial effect of eating carrots on those with vision loss due to vitamin A deficiency was well know before, and that may have been the inspiration for the story.