Mazel Tov! It’s a boy! The first Shabbos in the life of a new baby boy, we visit him and call the event “Shalom Zachor, greeting the newborn boy”. What is this all about?
The Taz (265) states that Chazal tell us that a baby is taught the entire Torah in the mother’s womb and before birth, an Angel “hits” the baby and all of their Torah is forgotten (and must be brought out with toil throughout their lifetime). Thus, the newborn baby is now in mourning over his forgotten Torah and so we come to visit him in order to comfort him.
I always understood three extensions from this:
1- That is why we say over Divrey Torah!
2- That is why we eat round chickpeas, as a mourner eats round items.
3- That is why we only visit a baby boy and not a girl, as his responsibly of Talmud Torah is larger.