The Gemara (Yevamot 62b) relates that Rabbi Akiva’s 24,000 students died between Passover and Shavuot because they lacked respect for one another. Consequently this became a period of semi-mourning in which weddings are not held and people refrain from haircuts. One the 33rd day (Lag) of the Omer the students stopped dying and the this is when the mourning period ceases. The Pri Hadash inquires: The only reason the students stopped dying on Lag BaOmer is because there were no more students left! Therefore Lag BaOmer perhaps should not be a day for celebration. The Arizal answers that on Lag BaOmer we celebrate the fact that the Oral Torah that we have to this day was restored and preserved by the five remaining students of Rabbi Akiva, including Rabbi Shimon Bar Yohai. Furthermore, Lag BaOmer is the Hilula (day of passing) of Rabbi Shimon Bar Yohai, which in itself is festive.
As mentioned above, one of the restrictions during the Omer is having a haircut. The Shulhan Aruch (Orah Haim 493:2) says that one should wait until at least the morning of the 34th day (Lamed Daled) of the Omer to get a haircut, even though the students stopped dying on the 33rd day. The Rama (ibid.) rules that in the Ashkenazic lands the custom is to permit haircuts on Lag BaOmer. The Pri Hadash rules like the Rama because he reasons that since the 33rd day is considered joyous, then there is no reason to wait till the next day. As for the Moroccan custom, some cities (Tangiers, Tetouan etc.) ruled like the Shulhan Aruch while other cities (Fes, Sefrou, Meknes, etc.) relied on the opinion of the Pri Hadash. According to the Arizal and those who follow Kabbalah, one should wait until Shavuot to have a haircut.
Summary: Whoever has a custom to take a haircut on the the 33rd day of the Omer may do so, otherwise one should wait till the 34th day.