It's largely a WWII British cover story.
During World War II, Britain's Royal Air Force had a new secret weapon: radar that helped its pilots find German bombers at night. According to a widely told story, to keep the technology secret, the British publicized that their pilots ate lots of carrots, which supposedly sharpened their night vision. Ace pilot John Cunningham, nicknamed "Cat's Eyes," became the face of the story.
At the same time, Britain's food ministry was encouraging people to eat home-grown carrots during rationing, and promoted them as helping people see during blackouts.
There's real science underneath. Carrots are rich in beta-carotene, which the body turns into vitamin A, and vitamin A deficiency causes night blindness. So carrots help if you're deficient.
But for people who already get enough vitamin A, eating more carrots won't improve vision. Eating huge amounts can even tint your skin slightly orange, a harmless condition called carotenemia.