The Talmud has an interesting comment concerning the passage in the Song of Songs "Go forth, 0 ye daughters of Zion, and behold King Solomon with the crown wherewith his mother crowned him in the day of his espousals and in the day of the gladness of his heart" (Song of Songs 3:11).
It is written in the Tractate Taanit that the day of his espousals is the giving of the Torah and the day of his heart's gladness is the building of the Holy Temple.
This implies that King Solomon (Shlomo) here refers to Peace (Shalom), and the King of peace, who is the Lord, celebrates a wedding and a great gladness of the heart on these occasions of Israel's initiation.
But what is the meaning of these days of his wedding and the building of the Temple?
The answer suggested by the Sages is that the gladness of the heart is the key, and the reason for the gladness is that "Prayer is instead of the sacrifices."
This is not necessarily the same idea that is superficially taught in the schools, that after the destruction of the Temple and the cessation of the ritual, the prayers in the synagogue substituted for the regular sacrifices.
This is not true historically or factually, not in relation to the First Temple, or even in regard to the Second Temple, for which we have much more literary and archeological evidence.
That is, we have clear-cut remains of synagogues from the period when the Temple was standing, as well as the literary references to prayer as a customary practice.
Nevertheless there is a sound foundation to this idea of prayer as a development of sacrifice.
The essence of both follows a similar vein.
To be sure, there are those who see prayer as only a psychological gesture, the speech of a person turning to God and unburdening his soul.
It is less costly than psychotherapy and enables one to express feelings and thoughts quite freely.
Prayer gives expression to two things.
First is a certain gratitude, a thankfulness for something that is not, necessarily connected to any particular event or circumstance.
An Israeli archeologist once told me that he had found some words cut into the stone wall of an ancient cave dwelling: "I thank the living God. . . ."
This was a spontaneous personal expression, like graffiti, without any connection to ritual or anything of a communal nature.
The other thing that prayer gives expression to is what is known as work, work in the heart.
This work, also called worship, is itself ritual, and not instead of ritual.
–Rabbi Adin Steinsaltz
From In the Beginning, “Faith and Prayer,” p. 257, by Rabbi Adin Steinsaltz