Presumably there was some sort of alternate or ending where Khan is shocked back to his senses by the sight of his child next to the Genesis device.
It would be a reasonable fall back position if the writers changed their minds about killing Spock or wanted to keep the secret by leaking the false ending.
Or maybe they were making a comment about how Khan's quest for vengeance has no bounds, that he is willing to sacrifice the product of the union with his wife to avenge her death while Kirk is ultimately rescued by his son sacrificing himself to save Saavik and Spock in the next film.
Throwing exploding children into a family movie is a bold move to say the least.