God made a covenant with Noah that He will not destroy the entire world again with a Flood. The symbol of this covenant is the rainbow.
When observing a rainbow, we recite a blessing: "Blessed is God, Who remembers the covenant (of Noah)."
However, the rabbis discourage one from staring at a rainbow, since it has a negative message: It is telling us that the world deserves (another) flood but because of God's covenant, it will not happen.
The Talmud relates that during the lifetimes of certain great sages, a rainbow was never seen, because they were capable of saving the world from a flood, in their own merit.
Rav Kook writes:
Were there not rainbows before the Flood? How did the rainbow suddenly become a symbol of protection from Divine punishment?
In truth, the rainbow was created immediately before the Sabbath of creation (Avot 5:6). Before the Flood, however, the rainbow could not be seen. It was a "Keshet Be'Anan," a rainbow in the clouds. The thickness and opacity of the clouds, a metaphor for the world's dense physicality — obscured the rainbow. Only after the Flood, in a world of diluted physical strength, did the rainbow finally become visible.
The rainbow is a symbol of weakness. Physical weakness, that the cloud no longer conceals it. And also spiritual weakness, that only a Divine promise prevents destruction of the world as punishment for its sins. The Sages taught in Ketubot 77b that rare were the generations that merited tzaddikim so holy that no rainbow could be seen in their days.
The Flood restored balance to the world in two ways. In addition to weakening the material universe, the aftermath of the Flood resulted in a bolstering of the spiritual and moral side, through the Noahide Code. The Flood annulled all previous obligations, and initiated a new era of repairing the world via the seven mitzvot of Bnei-Noah.
Read entire essay at Rav Kook Torah
Why was the rainbow chosen as a symbol of peace between Hashem and mankind?
Hashem said: "When I brought the mabul (flood), My bow was drawn against man. The rainbow resembles a reversed bow, signifying that there shall be no more "arrows from Heaven" sent to destroy humanity".
In the Torah portion that relates the establishment of the covenant between God and Noah (and all generations to come) by means of the rainbow, the word "covenant" (בְּרִית) is repeated seven times. These seven appearances of the word "covenant" allude to the seven colors of the rainbow studied and documented by Isaac Newton, and to the seven Noahide commandments.
The seven colors of the rainbow and the seven Noahide commandments correspond to the seven lower sefirot as follows:
RED - Gevurah (might) - The prohibition against murder
BLUE - Chessed (loving-kindness) - The prohibition against adultery
YELLOW -Tiferet (beauty) - The prohibition against theft
ORANGE - Hod (thanksgiving) - The prohibition against blasphemy
VIOLET -Netzach (victory) - The prohibition against idolatry
GREEN -Yesod (foundation) - The prohibition against eating the flesh of a live animal
INDIGO -Malchut (kingdom) - The injunction to establish a just legal system
by Rabbi Y. Ginsburgh
Also see: The Seven Universal Laws for all Humanity