Where did the phrase "you're it" come from in tag?

It's important to note that "It" in this sense is used by a number of children's games:

It, a term applied, in the games of young people, to the person whose lot it is to afford the sport. Thus, in Blindman's Buff, he who is blindfolded is It, in Loth. Hit. It is also used in Hy SpyTig, &c.
An Etymological Dictionary of the Scottish Language, 1825

Apparently, "He" was also used like this:

One-ery, two-ery, Ziccary zan; Hollow bone, crack a bone, Ninery ten:..Stick, stock, stone dead, Blind man can't see, Every knave, will have a slave, You or I must be He.
Gammer Gurton's Garland, 1810

The above are the earliest attestations in the OED for each word in this sense. Although the "He" quote is earlier, it's hard to tell which came first because it's not the type of thing that would be written down right away.


'It' as the name of the tagger in a game of tag

The earliest instances that various newspaper databases find of the designation "it" being used as the name of the tagger in a game of tag are from the 1860s.

From "Obedience," in the [Troy, Missouri] Lincoln County Herald (May 4, 1866):

"Where's the use of sitting down in the house such a splendid day? I can finish those little socks any time, but not just now? Mother wont be back for a good while, and there will be time enough ; now I mean to enjoy myself. Come, girls, for a run—tag! You're it Molly!"

From George Cooper, "Tag," in the California Farmer and Journal of Useful Sciences (October 14, 1869):

There's a lively little game,/ And you play it, everyone;/ "Tag" you give it for a name,/ And it's full of racy fun./ Here and there the players go,/ Till one chances to be hit,/ Then of course you let him know/ That he happens to be "it."

...

Tho' you like this game of "tag,"/ And you play with all your heart,/ When you're "it" you often lag/ Not so fine the "tagging" part;/ For I sometimes hear you shout,/ When your turn you have to share,/ Racing all the rest about,/ That "the playing isn't fair."

O, the smiling face for me,/ And the nimble hands and feet,/ That will take, and willingly,/ All the bitter with the sweet!/ So, hurrah for "tag," I say!/ And for everybody hit./ When another game you play,/ Just consider that I'm "it!"


Other names for the tagger in a game of tag

However, in North Carolina, at least, the tagger was not originally called "it" but "Buck"—to judge from "School-boy Days" in the [Raleigh, North Carolina] Spirit of the Age (June 6, 1855):

Who has forgotten ...and, though the Rules forbid, the mirth moving tag. Reader don't you remember how the tagger for the day was selected? Listen; it will awaken olden time memories:—

"Enny, meeny, moany, mite,/ Butter, lather, boney, strike,/ Hair, bit, frost, neck,/ Harrico barrico, we, wo, wack./

Eeny, meeny, tifty, te,/ Jeeno, Dinah, Domine./ Hocca, proach, Domma, noach,/ Hi pon, tas.

One-ery, two-ery, Hickory, Ann,/ Filliston, Follaston, Nicholas, John,/ Queeby, Quawby, Virgin Mary,/ Singlum, Sanglum, Buck!"

What a treat it was to be the last Buck in the "circle?" These blessed days come but once in a life-time.

The North Carolina version of the game seems to have involved having the same person be the tagger "for the day"—and further seems to have regarded being the last Buck in the circle as a highly desirable status. But whether "the last Buck" was the person left in the circle after all the other Bucks were selected by the singsong incantation and ran off to hide from the tagger, or whether it was the last person to be returned to the circle after the tagger had tagged all the others, I cannot tell.

Lina Beard, "Early Spring Amusements," in The Delineator (March 1901) relates the rules of a tag game played with hoops that seems related to the North Carolina game, even though it identifies the tagger as "it":

The game of Tag never loses its charm. What boy or girl can resist rushing after a companion at the words "last tag." No boy or girl with any daring or enterprise can rest content until the compliment be returned. Somewhat differing from the original tag, but none the less attractive is the pastime of the same name played with wooden hoops. "Hoop Tag," keeps one constantly on the alert. Any number may join in this game, and all except one, must be provided with hoops and sticks. Decide by some counting rhyme—such as

Ouery, oery, ichery Ann;/ Fellison, follison, Nicholas John;/ Queevy, quavy, English navy,/ Stingelium, stangelium, Buck—

who shall be "it." This important person has a stick, but no hoop. From some particular starting point determine the distance the players may roll their hoops befor "it" be permitted to follow. The distance is optional—eight yards or so would do, the place being designated by a house, tree or fence, as the case may be, and made plain to all by "it" saying, "I'll stand here and give you all a chance to reach that tree"—or whatever the object may be—"before I follow." At the signal, "Are you ready? Go!" from "it," all except "it" start at the word "go," rolling their hoops in the same direction. As soon as the first player reaches the tree "it" calls out "Coming!" and immediately follows. The other players, hearing the word "coming" scatter in all directions, while "it" endeavor to strike someone's hoop with his stick. When he succeeds the captive surrenders the hoop to it, who scampers away with his prize to join the others. The loser, instantly becoming "it," starts in pursuit of the nearest hoop. He cannot, however, strike the hoop he has just lost until the player has had time to run several yards beyond his reach. The game continues until each player has been "it."

An earlier source—Young Folks' Book of Games, Sports and Pastimes (1800) [combined snippets], refers to the tagger not as "it," but as "Tag" or "Touch":

TAG OR TOUCH.

Any number of boys can play at this game, which is an exceedingly spirited one. One of the players undertakes to be “Tag,” or “Touch,” and endeavours to touch one of the others as they are running about in all directions, trying to avoid him as much as possible ; if he can touch one, the player caught becomes Touch, and in his turn strives to touch one of his fellow-players. "Touch Iron" and "Touch Wood" are frequently called, and when the boys can touch either iron or wood, Touch has no power over them ; but the moment they quit either, they may be “touched;' and sometimes a touch makes prisoners.

Likewise, William Hoine, The Every-day Book and Table Book (1827) offers this brief gloss on tag:

Within memory, a game called Barley-break has been played among stacks of corn, in Yorkshire, with some variation from the Scottish game mentioned presently, In Yorkshire, also, there was another form of it, more resembling that in the “Arcadia,” which was played in open ground. The childish game of “Tag" seems derived from it. There was a "tig" or "tag" whose touch made a prisoner, in the Yorkshire game.


Conclusions

It thus seems possible that the tagger first became known as "it" because, in shouting "Tag, you're it" the tagger was transferring the identity of "Tag" (the tagger) from himself or herself to the newly tagged person. That is, "Tag, you're it" might have meant simply "You're the new Tag." But if that was ever the case, it ceased to be understood that way long ago. Today (and for many years past), children have understood "Tag, you're it" to mean "I just tagged you, and now you're 'it'."

Yet another possibility is that "Tag" is a corruption of "Stag" and that the original "it" was the "Stag" in one form or another of the game "Stag Out." Knox's Young Folks' Book of Games, Sports and Pastimes (1800) [combined snippets] has a description of this game as well:

STAG OUT.

A line should be drawn on the ground, at a little distance from a wall, to form "the bounds," and within which one of the players, as the "stag," stations himself; he then springs out, with his hands clasped firmly together, and endeavours to touch one of the other players, who all run from him. Should he succeed in touching one, he rides on his back home to the "bounds," and the player thus touched becomes Stag."

Although a couple of other bibliographies agree that this book was published in 1800, I haven't been able to confirm the date by direct inspection, so I can't say for sure that the claimed publication date is accurate. On the other hand, similar accounts of "Stag Out" appear in The Boy's Own Book (1843), The Boy's Treasury of Sports, Pastimes, and Recreations (1844), and The Boy's Book of Sports and Games (1851)—so it probably isn't far off. Also, Alice Gomme, The Traditional Games of England, Scotland, and Ireland (1898) cites a source she identifies as "Easther's Almondbury Glossary" as saying that a game called Stag that has some points in common with "Stag Out" was "So played in 1810, and is still."


I assume because it is a game constructed by children (playground game); therefore, it not being in the ideal grammatical sense is understandable.

As children, they have yet to grasp the English language adequately. Also, see.