Scripture teaches us that it's something man can reason out for himself:
Genesis
18:23 And Abraham drew near, and said, Wilt thou also destroy the righteous with the wicked?
18:24 Peradventure there be fifty righteous within the city: wilt thou also destroy and not spare the place for the fifty righteous that are therein?
18:25 That be far from thee to do after this manner, to slay the righteous with the wicked: and that the righteous should be as the wicked, that be far from thee: Shall not the Judge of all the earth do right?