Why is what happens to the boy unexpected in "Once Upon a Time?"
In the beginning of the overall story, Gordimer explains how she's been asked to write a children's story. Initially, she does not want to. Then, she describes waking up to a strange noise. At first, she fears an intruder is breaking into her home. Her fear stems from racial and political conflicts in the waning years of the apartheid in South Africa. (The story was published in 1989.) However, she realizes the noise is her house creaking over top of an underground mine. Given that this introduction or "frame" story ends with the elimination of fear, we might suspect that the subsequent "story within a story" (about the family) will have a "happily ever after" ending.
In the "story within a story," there is a family whose fear of crime and potential intruders causes them to increase the security of their home. This fear feeds upon itself and they continue reinforcing their home until it is more like the design of a prison. Given all of these precautions, one might think that the family will be completely safe and will "live happily ever after." However, their last addition of a jagged security coil ends up becoming a real danger. One of the brutal ironies of this story is that the little boy had been inspired by a fairy tale and tried to get through the coil:
Next day he pretended to be the Prince who braves the terrible thicket of thorns to enter the palace and kiss the Sleeping Beauty back to life.
Fairy tales usually have happy endings. The family takes drastic measures to make themselves safe in their home, which is why it is unexpected or even ironic that the little boy comes to harm because of those very measures and in defiance of the typical fairy tale ending.