There is a popular idea that seeing a rainbow is a bad sign, as if the world is deserving of a deluge (c"v) and the only reason Hashem does not do so is because of His promise. Is there any source for this? And if so, how does that square with the fact that rainbows are a natural occurrence caused by the refraction of light (as noted by Ramban in Parshas Noach 9:12)?
Is a rainbow a bad sign?
As was mentioned in the other answers, G-d tells Noach that he will never bring another flood to destroy the earth. The rainbow will be a sign, when G-d will see it he will remember the and refrain from destroying the earth (Bereshit 9:6-17).
In particular, verse 14-15 says:
"At a time when I bring clouds over the earth (i.e. When it will enter My mind to bring darkness and destruction to the world. - Rashi), the [rain] bow will be seen in the clouds. I shall remember my covenant that is between Myself and you..."
The Chayei Adam (63:4), quoted in the Mishna Berurah (229:1), says that one shouldn't point out a rainbow to someone else, since, as it says in Mishlei (10:18) "and he that uttereth a slander is a fool." (The slander in this case being that G-d is that the evil actions in the world is causing G-d to think about destroying the world, but He has refrained from doing so because of of the covenant he made with mankind)
The Midrash (Bereshit Rabba 35:2) tells us that there were two generations that did not see a rainbow. Rashi (Ketuvot 77B) explains that when the generation has leaders who are perfectly righteous, the generation does not need a rainbow so that G-d can remind himself not to destroy the world.
What about nature?
There is a disagreement amongst the various commentaries if rainbows existed before the flood. As quoted by @ArielK, the Ramban says that they existed before, but were now assigned to be a sign. The Ibn Ezra disagrees and says the rainbow was a new thing that was given after the flood. See here
There are many sources in Rabbinic Literature that talk about the Rainbow being created before the flood. For example, Avot 5:6 ("10 things were created on twilight of the sixth day...the rainbow...") - see footnote 4 here
The Seforno (9:13) seems to say that there is a second (or double) rainbow with inverted colors that is a sign for the Tzadikim of the generation that their generation needs to be taught and led down a path of repentance (I think that's what he says).
The Kli Yakar (9:14) says that the reason the people in the righteous generations didn't see a rainbow isn't because it wasn't there, but because they didn't bother to look for it. On the other hand, sinners are always looking up to make sure they see a rainbow to remind themselves that G-d won't destroy the world because of their sins.
So the rainbow being a sign kind of becomes a self-fulfilling prophecy, reminiscent of the Jewish saying, "The hat burns on the head of the thief"
R' Yonatan Eibshitz (Ye'Aros Dvash 1:12) quotes a Zohar that says that there are two kinds of rainbows, natural rainbows and unnatural rainbows. The unnatural rainbow is the color of T'chelis and is the one that is a sign that we are worthy of destruction (T'chelis is similar to the word Kilyon, destruction). However, most Rabbis disagree with this (see Ben Ish Chai, Ekev:17).
The Netziv, in his Emek HaDavar 9:13-17, says that the sign that G-d wants to destroy the world is if the rainbow is seen briefly and then immediately concealed. G-d wants to flood the world (hence the heavy clouds which completely block the sun - no sun, no rainbow), but doesn't because of his vow.
Rabbeinu Bechaya, in a Kabalistic interpretation, points out that it says "I put my rainbow in the cloud". He says that this is not referring to natural rain clouds, but rather to a specific cloud, G-d's glory, which (Shemot 16:10) is referred to as "appearing in the cloud". He says that Keshet means strength and judgment, and the sign G-d is angry is that the attribute of judgment is apparent in the revelation of His glory.
Building on the idea that the flood purified the world (one of the reasons why the flood was 40 days is because a Mikva is 40 Se'ah), The Lubavitcher Rebbe says that the flood refined the world and made lighter, thinner clouds, which made rainbows possible (In other words, rainbows are a natural thing that were theoretically possible from the time of the creation of the world, but it took the flood to create conditions that made seeing a rainbow possible). (See here for an English translation of a Ma'amar where the Rebbe discusses the spiritual idea of clouds and talks about rainbows. See here for a discussion about the difference between a pre- and post-flood world, and how this relates to the rainbow). - The Kli Yakar (9:14) quotes a very similar idea in the name of מהרי"א (The Abarbarnel).
Is there nothing good about rainbows?
There are however, good aspects to the Rainbow as well. In Yechezkel 1:28, the appearance of G-d is compared to the appearance of a rainbow. (This is why the Talmud says that excessively staring at a rainbow is disrespectful to G-d (Chagiga 16A - see there for another reason as well). It is also brought in Shulchan Aruch Orach Chaim 229:1)
The Zohar, (Vol. I, p. 72b) quoted and explained here says, "Do not expect the coming of Mashiach until the rainbow is seen... in shining colors."
After the Flood, G-d imbued the world with a new potential -- the potential to create. He granted it the ability to take what it receives from Above and develop it, extend it, and expand upon it. ...such a world is more enduring: Even when it loses sight of its origin and purpose, it retains the ability to rehabilitate itself and restore its relationship with its Creator...When this world goes astray, G-d sees its rainbow, and the sight causes Him to desist from destroying it. For the rainbow attests to the world's new maturity -- its ability to ultimately rise above its present lapse and rebuild its relationship with its Creator. (see here for context and more details)
Rashi on pasuk 14 seems to indicate this idea.
The Ramban there explains that God is saying that from now on it will be a sign that He will not destroy the world:
ולכן נפרש הכתוב, הקשת אשר נתתי בענן מיום הבריאה תהיה מן היום הזה והלאה לאות ברית ביני וביניכם, שכל זמן שאראנה אזכיר כי ברית שלום ביני וביניכם:
Perhaps one can explain that God causes the conditions for a rainbow to appear when He wants to send such a message. Though I think Ramban differs with Rashi on interpreting the sign.