Hannah had asked Yahweh for a baby and promised him that she would give the baby to serve in the temple.
This means where Yahweh could see him and Samuel could learn about Yahweh.