After the Lord destroyed every living thing on the earth except what was preserved on the ark – and I suppose some sea life, too, the scriptures say, “And the bow shall be in the cloud; and I will look upon it, that I may remember the everlasting covenant between God and every living creature of all flesh that is upon the earth. And God said unto Noah, This is the token of the covenant, which I have established between me and all flesh that is upon the earth.” (Genesis 9:16-17) The rainbow was to be a sign of a covenant that God made between Himself and all flesh. But what covenant is it a token of? Part of the covenant was that God would no longer destroy the earth by flood. Genesis 9:11-15
11 And I will establish my covenant with you; neither shall all flesh be cut off any more by the waters of a flood; neither shall there any more be a flood to destroy the earth.
12 And God said, This is the token of the covenant which I make between me and you and every living creature that is with you, for perpetual generations:
13 I do set my bow in the cloud, and it shall be for a token of a covenant between me and the earth.
14 And it shall come to pass, when I bring a cloud over the earth, that the bow shall be seen in the cloud:
15 And I will remember my covenant, which is between me and you and every living creature of all flesh; and the waters shall no more become a flood to destroy all flesh.
But the rainbow was also to help us look forward as well. It was to remind us that if we keep the commandments, Zion will return to the earth. Enoch’s people became so righteous that they were taken up into heaven. And when God’s people embrace the truth and look upward, Zion would look downward, and there would be great joy. The rainbow reminds us that not only is God in control, but someday the Savior will return as the rightful heir to the government of earth.
The Joseph Smith Translation of the verses (JST) gives the account:
21 And the bow shall be in the cloud; and I will look upon it, that I may remember the everlasting covenant, which I made unto thy father Enoch; that, when men shall keep all my commandments, Zion should again come on the earth, the city of Enoch which I have caught up unto myself.
22 And this is mine everlasting covenant, that when thy posterity shall embrace the truth, and look upward, then shall Zion look downward, and all the heavens shall shake with gladness, and the earth shall tremble with joy;
23 And the general assembly of the church of the first-born shall come down out of heaven, and possess the earth, and shall have place until the end come. And this is mine everlasting covenant, which I made with thy father Enoch.
24 And the bow shall be in the cloud, and I will establish my covenant unto thee, which I have made between me and thee, for every living creature of all flesh that shall be upon the earth.
25 And God said unto Noah, This is the token of the covenant which I have established between me and thee; for all flesh that shall be upon the earth. (JST GENESIS 9: 21-25 )