Lag BaOmer is an enigmatic semi- holiday, of which the Shulchan Aruch speaks in terms of "a bit of joy", which grew to a festive day of major proportion in the Chassidic world.
Lag BaOmer should be seen in the context of the whole Omer period, in order to be properly understood. From the perspective of the Torah, the Omer period is analogous to Chol HaMoed, being sandwiched between Pesach and its Atzeret, Shavuot. In the context of the Beit HaMikdash, the period of counting runs from the bringing of the first Barley offering to the Two Loaves (from wheat flour) on Shavuot. The Omer corresponds to the preparatory period between Y'tzi'at Mitzrayim and Matan Torah, during which time, a nation that had just emerged from long slavery and oppression prepared itself physically, psychologically, and spiritually for the great events at Sinai.
All indications point to the Omer being a joyous period. The mournful aspect of the Omer came in two stages: With the destruction of the Beit HaMikdash and the cessation of the Omer and Shtei HaLechem offering, the counting of the Omer became "hollow". A vacuum was created. We continued to go through the motions of counting, but without the "from" and the "to", something was missing, to say the least.
Then comes the Talmud account of the tragic deaths of the students of Rabbi Akiva. The combination of when they died, why they died, AND the emotional vacuum of the Omer, resulted in the Sages ordaining practices of mourning during these days. Having died during this time of the year would not have, by itself, shaped the present nature of these days. But the statement in the Talmud (Y'vamot) that they perished because they didn't treat each other with respect - this has an ironic element that the Sages chose not to overlook. During the seven weeks from the Exodus to Sinai, when the Jewish People were preparing themselves to be worthy of receiving the Torah, how sharp is the implied lesson and warning - see these scholars? High marks in the Torah-learning side of the issue. But a human failing on an interpersonal level. This cannot be. And this is what our Sages wanted us to think about during this pre-Shavuot period. It was then natural to include mourning the devastation of the Crusades during the Omer as well.
As far as Lag BaOmer is concerned, several factors combine to define its nature. That the students of Rabbi Akiva "stopped dying" on the 33rd day, or they died during a 33 day period, or on a total of 33 days (these are different opinions as to what happened), prompted the Sages to make a statement on day 33 of the Omer, to allow that day to represent the turnabout from the tragic nature that the Omer had developed.
Pri Chadash raises the question: why celebrate when the students of Rabbi Akiva stopped dying, if they were all gone? His suggested answer is that "they stopped dying" represents the hope for the future, that Torah learning and scholarship has not ended with their deaths. Rabbi Akiva would have more students and many Rabbi Akivas will have many many students. Lag BaOmer is not an intrinsically happy day, but it represents the bright promise of the future. Behavior on Lag BaOmer differs from community to community - some allow weddings, some don't; some cut hair, some don't - yet in all cases, Lag BaOmer stands out as a bright day in contrast to the mournful flavor of the rest of the Omer.
It's almost as if each day of the Omer says "just give me an excuse to be festive again and you'll see what I can be, you'll see what I should be.
The original days of the Omer (right out of Egypt) were days of potential that came to fruition at the foot of Har Sinai.
The students of Rabbi Akiva represent another kind of potential, both in the pursuit of Torah scholarship as well as in the Bar Kochba revolt (which is another element in the story). These potentials were not realized. The Omer stands for both kinds of potentials: the fulfilled and the not yet fulfilled.
The Chatam Sofer says that it was on the 18th of Iyar (Lag BaOmer) that the Manna began to fall. This is based on the idea that the food supply (matza) that we brought out of Egypt lasted until the 14th of Iyar (which marks the 14th of Iyar as the end of the Pesach Time Frame, hence its choice by G-d for Pesach Sheni). Then the people went hungry for three days - 15,16,17 of Iyar, complained, and received the Manna on the 18th. This adds to the celebratory nature of Lag BaOmer.
Finally, we come to Rabbi Shimon Bar Yochai. Forced into hiding, his success in all areas of Torah, esp. the hidden, mystical dimensions, show us the great potential, and the realization of the potential that defines Living Judaism.
So it his yahrzeit, and more, the reflection on his life and accomplishments, that allows Lag BaOmer to stand up and say: Remember - this mournful behavior is only temporary. We must continue to grow in Torah and we will be privileged to the rebuilding of the Beit HaMikdash, speedily in our time. And then the days of the Omer — all of them — will be restored to their joyous potentials. Until then, we celebrate the life of the great Rabbi Shimon Bar Yochai, and rededicate ourselves to G-d and Torah.