In the order of the prayer as we have it in the Siddur, at the end of the Shacharit, Mincha, and Arvit, we find the prayer of “Alenu Le’Shabe’ach La’Adon Hakol.”
The Responsa of the Geonim (Shaare Teshuva, Chapter 43) states that this prayer was not authored by our Sages, as other prayers were. Rather, Yehoshua bin Nun instituted that this prayer be recited every day, in order to distinguish between the Jewish people and the other nations of the world. This prayer was recited by the Jewish people as they circled Jericho until its walls fell.
We also add the “Al Ken Nekaveh Lach” text, for this was also instituted in that generation to be recited daily.
One must take great care to recite “Alenu Le’Shabe’ach” with great concentration, for it has tremendous power to allow all of the Heavenly abundance generated by our prayers to be showered upon us. Indeed, there are certain impure forces in the world and after the Jewish nation concludes their prayer, when Hashem showers abundance on the world, these impure forces snatch this goodness for themselves since some of those individuals who prayed are not worthy of receiving it. However, by reciting “Alenu Le’Shabe’ach,” we, so-to-speak, “save” this abundance and keep it for ourselves, in pursuit of holiness and service of Hashem. The Ari z”l teaches that when one recites the words “Shehem Mishtachavim La’Hevel Va’Rik,” one subdues the forces of impurity. The “Alenu Le’Shabe’ach” prayer is so precious that our Sages saw fit to insert it into the Mussaf Amida during the Days of Awe.
Maran Ha’Chida writes in his Sefer Moreh Be’Etzba (Chapter 2):
“One should recite the text of ‘Alenu Le’Shabe’ach’ at the conclusion of every prayer service. One should recite it word by word. One should not recite, ‘U’Mitpalelim El El Lo Yoshia Va’Anachnu Mishtachavim,’ rather, one should pause for a moment and then say ‘Va’Anachnu.’ This is an awesome praise and is full of great secrets. The primary text was drafted by Yehoshua bin Nun, and Rabban Yochanan ben Zakai enacted that it be recited after every prayer. Our great Rabbeinu Ari z”l revealed its secret in that it is meant to continue the surrounding lights (of our prayers).”
The Acharonim write that there are many Segulot associated with reciting “Alenu Le’Shabe’ach” and it is beneficial in times of distress. Some actually recite it when one is about to pass on.
Hagaon Mishnah Berura (Chapter 65) writes that if one happens upon a Minyan that is concluding their prayers and they are reciting “Alenu Le’Shabe’ach,” one must rise and recite it along with the congregation. (However, if one is busy studying Torah, one need not recite it along with the congregation.)