In the Gemara when there is a dispute between Beit Shammai and Beit Hillel, if the halacha always goes according to Beit Hillel, why is It it necessary for Beit Shammai’s opinion to be recorded?
Also why is the Halacha always like Beit Hillel?
Although the halachah follows Beis Hillel, the opinion of Beis Shammai is recorded because it is still Torah.
The Gemara therefore teaches that “these and these are words of the living G-d”. Although the halachah can only follow one opinion, both remain a part of the Torah, and the Sages wished to ensure that all are written for posterity.
Moreover, the Mishnah in Edios records a dispute concerning why minority opinions are recorded. According to the Rabbis, it is because future generations might rule like the opinion which is currently in the minority (and therefore not halachah).
The Gemara states that a Divine voice (bas kol) declared that the halachah follows Beis Hillel, the reason being that they are more humble than Beis Shammai.
In practice, the majority of Sages always followed Beis Hillel, and therefore the halachah followed their opinion, with the exception of a number of halachos that were established at a time when Beis Shammai were the majority (the “18 matters”).