Our Gemara on Amud Aleph discusses how during the festivals, because it was a time of overall rejoicing and mingling of many people, there was a greater susceptibility to sexual transgressions. (Some say this is the source for the custom of fasting "Behaab" after Pesach and Succos.)

Tiferes Yosef (Shavuos 15) provides a spiritual and psychological insight. Yom Tov induces a joyful state that, when properly channeled, leads to attachment to God. God is the source of all completeness, thus feeling joy and completeness logically lead to spiritual attachment. However, he cautions that when this state is aroused but not properly directed, it can lead to a greater downfall due to hedonistic indulgences.

In general, this is an important point about the potential for good and evil in everything we experience. Any emotion or experience that arouses us can pull us in either direction. We can be drawn closer to God or toward our own selfishness. The state of joy, pleasure, or excitement is simply part of the human experience that needs to be properly harnessed.

We find another powerful psychological example in the divergent paths chosen by Rus and Arpah. The Gemara and Midrash tell us that once Arpah decided to return to her people and not follow her mother-in-law and Rus, she ended up participating in a sexual orgy (Sotah 42b and Tosafos). How did Arpah go from considering a profound sacrifice and conversion to Judaism to the extreme of complete hedonism? This phenomenon is a powerful aspect of human nature. Once something is aroused, the void it leaves must be filled. Because Arpah had initially sensed a great moment and was at least partially aroused to attach to God, and then repressed that urge, the unconscious longing and emptiness remained active, driving her to seek oblivion.

It's important to recognize that even those, and perhaps especially those who succumb to sexual temptations, may harbor deep longings for attachment and connection within their psyche. Unfortunately, in the midst of their desires and impulsive behaviors, they have not been able to channel their aspirations toward spiritual goals. Yet, the potential for attachment and connection remains.