The setting for Jesus’ teaching in John 7:37-39 sets the stage for an amazing declaration and invitation by Jesus.
It’s the final day of the festival of booths.
This festival was a time where many people would build temporary shelters out of branches and lived in them for a week in order to commemorate the Israelites sojourn in the wilderness. It was the most popular of the three required Jewish feasts in Jesus’ day.
But the last day was when the real excitement happened… the Ceremony of the water drawing
The Mishna states, "He that has never seen the joy of the [ceremony of the water drawing] has never in his life seen joy." (Sukkah 51a) As the ceremony took place, Levite's played lyres, trumpets, harps, cymbals, and other instruments, while other Levite's sang. In the Temple area, three golden candlesticks nearly 75 feet high were lit by young boys climbing tall ladders, and the light from these candlesticks could be seen throughout all Jerusalem. Respected men of faith danced and sang in front of these candlesticks while carrying burning torches. As the ceremony progressed through the night, the priest blew the shofar three times. In the manner of the text of Isaiah 12:3, "Therefore, with joy shall ye draw water out of the wells of salvation," the evening was characterized by exuberant joy. It was a wonderful occasion that no one wanted to miss. (from book https://www.amazon.com/Feasts-Israel-Seasons-Messiah/dp/0915540142)
Sometimes Rabbis would perform acrobats and juggle flaming touches as part of the festivities.
The ceremony of the water drawing on the last day was important.
The water came from a spring east of Jerusalem called the Spring of Gihon which may have been used to anoint David’s son Solomon, King of Israel (1 Kings 1:45).
King Hezekiah later redirected the water of this spring into the city of Jerusalem through a long underground conduit known as Hezekiah's Tunnel. (2 Kings 20:20)
Within the walls of Jerusalem, the waters of Gihon ran into a pool named the Pool of Siloam. (involved in the Red Heifer ordinance Numbers 19 and John 9 when Jesus healed the blind man)
During this water ceremony they would read the Scriptures
Ezekiel 47 - In my vision, the man brought me back to the entrance of the Temple. There I saw a stream flowing east from beneath the door of the Temple and passing to the right of the altar on its south side. 2 The man brought me outside the wall through the north gateway and led me around to the eastern entrance. There I could see the water flowing out through the south side of the east gateway. ….
Zechariah 14 - 8 On that day life-giving waters will flow out from Jerusalem, half toward the Dead Sea and half toward the Mediterranean,[d] flowing continuously in both summer and winter.
9 And the Lord will be king over all the earth. On that day there will be one Lord—his name alone will be worshiped.
What it would look like
Early on each of the seven mornings of the feast the high priest would lead a procession from the Pool of Siloam to the temple [7 times on the last day!]. Another priest would first fill a golden pitcher with water from the pool. He would then carry it through the Water Gate, which was located on the south side of the temple, and into the temple courtyard. There he would ceremoniously pour the water into a silver basin on the west side of the bronze altar, from which it would flow through a tube to the base of the altar.
Then they would both pour the water and the wine out before the Lord. The pouring out of water represented God's provision of water in the wilderness in the past and His provision of refreshment and cleansing in the messianic age. The pouring out of wine symbolized God's bestowal of His Spirit in the last days.
Every male present would simultaneously shake his little bundle of willow and myrtle twigs (his lulab) with his right hand and hold a piece of citrus fruit aloft with his left hand. The twigs represented stages of the wilderness journey, marked by different kinds of vegetation, and the citrus fruit symbolized the fruit of the Promised Land.[559] Everyone would also shout three times: "Give thanks to the LORD!" Worshippers in the temple courtyard would then sing the Hallel (Ps. 113—118). This was such a happy occasion that the Mishnah stated: "He that never has seen the joy of the Water-drawing has never in his life seen joy."
This water rite had become a part of the Israelites' traditional celebration of the Feast of Tabernacles. Essentially it symbolized the fertility and fruitfulness that the rain brought.
He announced that He was the One who could provide messianic blessing: that He was the Messiah. Jesus' words compared His own Person to the rock in the wilderness that supplied the needs of the Israelites.
and all of them drank the same spiritual water. For they drank from the spiritual rock that traveled with them, and that rock was Christ. 1 Corinthians 10:4 NLT
Some information was received from this webpage - https://jewishroots.net/library/holiday-articles/water_libation_ceremony.html
And this video - https://youtu.be/g4_GO511YSo.
And these notes - https://planobiblechapel.org/tcon/notes/pdf/john.pdf