In short, a long time.
The continuation of the lottery is dependent on its acceptance as tradition, and this sense of tradition is well ingrained in the minds of the townspeople. The lottery has been a staple of life for so long that people do not only not question its purpose but don't like "to upset even as much tradition as was represented by the black box." The townspeople have accepted the necessity of the lottery for their entire lives, and it must thus continue.
Old Man Warner, the oldest man in town at age seventy-seven, is younger than the current black box the town uses for the lottery. The original materials they used have been lost so long ago that no one has any real idea of what paraphernalia was used when the lottery began. Rumors speculate that the current box contains pieces of the original box, but no one alive knows this with any certainty.
As far as Old Man Warner is concerned, "There's always been a lottery," and there shall always be a lottery. We can assume that if those in Old Man Warner's generation had any direct knowledge of the origins of the lottery via their own parents and grandparents, those details would be more clear. However, since even the nearly eighty-year-old man in town has no direct knowledge of the lottery's first days, we can assume that it has been occurring for at least a couple of hundred years.
We don't know exactly how long the village has been holding the lottery but we can make educated guesses. We are told that:
The original paraphernalia for the lottery had been lost long ago, and the black box now resting on the stool had been put into use even before Old Man Warner, the oldest man in town, was born.
If Old Man Warner is in his eighties, the black box now used for the lottery could be estimated to be at least ninety years old. However, it is probably not the first box made, as we learn the "original paraphernalia" had been lost long ago. From the mention of the newer black box, we can assume that part of the lost original paraphernalia was an older box. This would suggest that if lottery boxes last ninety years, the lottery is at least 180 years old. Since the story takes place in the late 1940s, that would date the traditional back to the mid-1700s.
However, given that it is a lottery meant to insure a good harvest, we can probably safely date it back to a more precarious time for early New England settlers, such as to the mid-1600s. That was a pre-Enlightenment era, when scientific knowledge was far inferior to what it is today, and people were more apt to lean into superstition.
These are all educated guesses. The main point is that the lottery has been going for the entire lives of the people assembled. It is an entrenched tradition that is difficult for the villagers to abandon, even if it is barbaric and unnecessary.
The precise origins of this annual ritual have been lost to the mists of time. We never discover exactly how old it is, but it most certainly is old. The lottery's original paraphernalia has long since been lost, but the black box used to draw the tickets has been in use since before Old Man Warner was born, and he's the oldest man in town.
This is a pagan ritual, an ancient sacrificial rite whose ultimate origins hark back to the dawn of civilization. The more the lottery is shrouded in mystery, the more easily it can be presented as a reenactment of the wisdom of our ancestors. Among other things, this serves to justify its continuing centrality in the social life of the town.
The omission of the precise age of the lottery can also be justified on purely literary grounds. If Jackson had revealed this information, then it would have made the ritual much less mysterious and intriguing. By refusing to put an exact date on the ritual's origins, Shirley Jackson does what any good writer of fiction should do—allow readers to use their own imaginations.
In "The Lottery," Jackson does not reveal for how long the lottery has been played by the townspeople. We can infer its history, however, based on some details from the story. Old Man Warner, for example, is the oldest man in town and when he walks through the crowd, he claims that this is the seventy-seventh lottery in which he has taken part. We can assume, therefore, that the lottery is at least seventy-seven years old.
There is some evidence, however, to suggest that the lottery is even older than Warner. Early in the story when Jackson describes the lottery "paraphernalia," for instance, she comments that the current black box has been in use since before the birth of Old Man Warner.
The lottery, then, is older than the living memory of anybody in the town and this adds to the sense of mystery which surrounds this violent ritual.