Well, if we look at the bible,  God wanted to be forgiven after The Flood after killing millions of people,  including kids, therefore he decided to make a rainbow in the sky to show us he was now  at peace with humans. 