As described in Edut L’Yisrael: Sheiruta di’Tzlota (a text on customs surrounding weddings and births in Judaism, published in Israel c. 1960), the current practice appears to be a combination of two distinct customs.
Firstly, as stressed in the Kabbalistic sources, the night before the circumcision is considered a spiritually dangerous time for the baby; as such, the father would gather ten men to conduct a vigil to study Torah to protect him from metaphysical damage. Thus, this night is given the Yiddish name, “night of watching [or ‘guarding’]”.
Secondly, non-Kabbalistic sources describe a practice several centuries old that on the Friday night before the bris milah, a melamed would take his preschool-age students to say Shema near the baby, and afterwards receive candy (or their equivalent at that point in history, namely nuts or dried fruit.)