[ Religion & Spirituality ] Open Question : Why did god flood the world if there were some good people.?

The world was full of sin and he flooded it. But not all were living lives of sin, so why did he just go and make a flood to kill all those people and other innocent organisms if he truly does care about us?