Because they had no choice in the end.
Recall that the original bomb was merely intended to destroy the stargate so that it could not be used to threaten Earth.
However, the bomb had been altered by Ra to be 100 times more destructive than the original. Essentially it was a planet wrecker.
Consequently, unable to stop the countdown or disable the device O'Neil and Jackson used the only option available. Send it back into Ra's ship in space to save both Earth and the desert planet (that would eventually be called Abydos)...and perhaps, not coincidentally, blow Ra to hell.
Assuming the children were still on the pyramid, which seems likely, they were also killed.