Rav Menachem Mendel of Rimanov, one of the early Hasidic Rebbes, explained that the custom is based on the Midrash which states that all the days of Rebbe Shimon bar Yochai, the rainbow didn't appear in the sky. (Ketubot 77b the same is said there of Rebbe Yehoshua ben Levi.) Rashi explains that the rainbow is the sign of the covenant that the world will not be destroyed, and if there is a perfect tzaddik in the world there is no need of such a sign. (Cited by B'nei Yissachar on Lag BaOmer.)
The somewhat surprising connection between the rainbow and an ordinary bow is made by the Ramban's commentary on the Torah. He explains that the rainbow is a sign of peace because it shows a weapon, the bow, in a harmless state pointing away from the earth and with no bowstring (Bereshit 9:12). But now the symbolism seems confused in the time of Rebbe Shimon the world was not even in need of the rainbow, depicting a harmless bow; yet today we commemorate this period by shooting with an actual bow and arrow!
One explanation is that in the time of Rebbe Shimon, the utter holiness and abstinence he displayed were a realistic aspiration for the many. Not only Rebbe Shimon, but also his students were so absorbed in Torah that they were exempt from prayers (SA OC 106:2). And Rebbe Shimon asserted that every person should refrain from worldly pursuits, while later Sages concluded that this path was appropriate only for the few (Berakhot 35b, according to Maharsha).
Since Rebbe Shimon's passing, we don't have a perfect model of total devotion to Torah study among us. We have no choice but to serve HaShem in other ways, including via prayer and occupation with worldly affairs. We show this on Lag BaOmer by a worldly pursuit which exemplifies this contrast using bow and arrow.
Here is an alternative explanation. Rashi explains that Yaakov Avinu refers to a bow as a metaphor for prayer (Bereshit 48:22). This is based on the fact that Esav sought favor with Yitzchak with bow and arrow and was blessed by him with weapons of war (Bereshit 27:3, 27:40), whereas Yaakov's tool is his voice which he uses in prayer (27:22). There is also a play on words because "bekashti", "with my bow", can be read "bakashati", my prayer. (See Maharsha and Iyun Yaakov on Bava Batra 123a.) Of course it is also an appropriate metaphor because a prayer which is uttered with careful kavana (inention) can have far reaching effects, just like an arrow sent from a bow with precise kavana (aim).
All the time of Rebbe Shimon, there was no rainbow in the sky hinting at the fact that his Torah study was so encompassing that it transcended the need for prayer, the "bow" of Israel. But today there is no one at that level, as the Shulchan Arukh states (OC 106:2). The message of the remarkable Lag BeOmer custom is that nowadays we have to leave the Beit Midrash and pick up bow and arrow, that is, interrupt our Torah study to pray.