And when the female [infant] buried alive [as the pagan Arabs used to do] shall be questioned. For what sin she was killed?
So in a similar fashion Allah [swt] will question the innocent for what sin they were executed.
When the earth is shaken with its (final) earthquake. And when the earth throws out its burdens. And man will say: “What is the matter with it?” That Day it will declare its information [about all what happened over it of good or evil]. Because your Lord has inspired it. That Day mankind will proceed in scattered groups that they may be shown their deeds. So whosoever does good equal to the weight of an atom [or a small ant], shall see it. Whosoever does evil equal to the weight of an atom [or a small ant], shall see it.
Allah [swt] will establish the Day of Judgement for His perfect Judgement.
And We shall set up balances of justice on the Day of Resurrection, then none will be dealt with unjustly in anything. And if there be the weight of a mustard seed, we will bring it. And sufficient are We as Reckoners.
And Allah [swt] will not be unjust to the innocent wrongfully executed.