According to the Encyclopedia of Play In Today's Society, it can be traced back as far as 2nd Century (BCE) Greece. Julius Pollux apparently described a game called Apodidraskinda, which involved choosing one player who would keep their eyes shut for a set time, and then try to find the other players. But this was a variant of the game where everyone else tried to make their way back to the starting point (with the first person there becoming the new "seeker").
There's lots of evidence of the game being well-established in Elizabethan England, again with slight variations. The game "King By Your Leave," for example, was exactly the same as Apodidraskinda. In 1572, Richard Huloet described it as:
"A playe that children have, where one sytting blyndefolde in the midle, bydeth so tyll the rest have hydden themselves, and then he going to seeke them, if any get his place in the meane space, that same is kynge in his roome."
There are also two likely references to hide-and-seek-like games in Shakespeare: one in Love's Labors Lost, when Biron says "All hid, all hid; an old infant play," and one in Hamlet, when Hamlet makes a reference to a hide-and-seek-like game called Hide and Fox when he says "Hide Fox, and All After" (in reference to Polonius' body).
It's worth noting that the game is present in many different cultures, which likely did not inherit it from the Greeks. According to the Britannica entry on this, for example, there's an Igbo game called oro in Nigeria which is very similar. It's very likely, in other words, that children would come up with much the same game in multiple places and at multiple times, in much the same way that there are variants of "tag," footraces, etc, in children's play all over the world and throughout history.