Holy works teach us that in Egypt, the Jewish people were sunk into forty-nine gates of impurity. Upon leaving it, each day counted as a higher level of ascent from that impurity to holiness. By Shavuos, they had reached forty-nine levels of kedusha, up until the fiftieth, which is the gateway to understanding. The author of Ayeles Hashachar said that the gates of contamination are congruent to the gates of holiness. In the process of purification, the Jews would gradually emerge from a gateway of impurity and enter a gateway of holiness.
We should not be misled to understand that there is a reality of a gateway of holiness which one can enter and remain there, while continuing to conduct oneself as before. There is no such situation. Emerging from a gateway of impurity involves a work of self-improvement of one's personal failings and faulty deeds, of elevating oneself in perfecting one's character — and only thus, being able to enter the gateway good character traits which one has thus acquired.
The ascent of the Jews after the Exodus was made possible by improving their middos. Pride is one gateway of impurity; desire and the pursuit of honor are other gateways of sinfulness. Indeed, all negative traits are gateways of tumah in which a person wallows.
The Jews lifted themselves up from faulty traits, entering the pure gateway of humility, and similarly with all other negatives attributes. This was made possible through heavenly assistance and the heavenly illumination which Hashem shone upon them, step by step, until their self-perfection made them compatible for the unity of heart achieved by Rosh Chodesh Sivan, a tremendous level.
Each of us knows how difficult it is to be capable of unity of heart with his fellow Jew. Preventing this is envy, personal desires and the need for honor and respect. Each one of these negative traits get in the way of achieving true unity with one another.
Twenty-four thousand disciples of Rabbi Akiva died during the Sefira period between Pesach and Shavuos. These very days are especially conducive for elevation towards the giving of the Torah.
If we do not properly mend our character flaws, if a person is steeped in his faulty traits, he arouses heavenly accusation and prosecution. Rabbi Akiva's disciples were of impeccable stature but Hashem demands from tzaddikim a hairline perfection so that the charges against them was very weighty.
When fault is detected in interpersonal matters where they did not show sufficient respect for one another, the attribute of Justice was aroused and struck them down during this time between Pesach and Shavuos.