In the first place, the children were abandoned in the woods by their parents because there wasn't enough food to feed the family:
... And at one time when there was famine in the land, he could no longer procure daily bread... "I'll tell you what, husband... tomorrow morning we will take the children out quite early into the thickest part of the forest. We will light a fire and give each of them a piece of bread. Then we will go to our work and leave them alone. They won't be able to find their way back, and so we shall be rid of them."After wandering the woods, the children find the house made of bread and roofed with cake, with windows of transparent sugar. They start to eat the house, which is inhabited by the wicked witch...
Whenever she could get a child into her clutches she cooked it and ate it, and considered it a grand feast...But she has to fatten up Hansel:
"Fetch some water and cook something nice for your brother. He is in the stable and has to be fattened. When he is nice and fat, I will eat him."Here is Arthur Rackham's illustration of the encounter, via the OBI Scrapbook Blog: