“And they stood under the mountain.” (Exodus 19:17) Rabbi Avdimi bar Hama bar Hasa said: This teaches that the Holy One Blessed Be He, overturned the mountain upon them like an [inverted] cask, and said to them, ‘If you accept the Torah all is well, but if not, then there will be your grave.’ Rabbi Aha bar Yaakov noted, ‘This furnishes a strong protest against [observance of] the Torah.’ Raba said, ‘Be that as it may, they accepted it in the days of Ahashverosh, for it is written, “the Jews observed and accepted” (Esther 9:27) - they observed what they had already accepted. -- Shabbat 88a.
One of the most fundamental values of the human condition is that of free will. Rambam (Hilchot Teshuva 5:4) explains that reward and punishment is predicated on man’s ability to exercise his free will and thus be held accountable for his actions. In contradistinction, coercion is something reviled as negating the value of free will. It 
It is thus with great consternation that we read in the Gemara that God forced the Jews to accept the Torah.
is thus with great consternation that we read in the Gemara that God forced the Jews to accept the Torah.

It is thus with great consternation that we read in the Gemara that God forced the Jews to accept the Torah.

Further enshrouding this enigma of coercion is the fact that the Jews are so wholly praised by the same Gemara for accepting the Torah with the famous expression of unreserved selfless acceptance - naaseh v’nishmah - “we will do and we will hear.” (Exodus 24:7) If the Jews had already accepted the Torah of their own volition, what is the meaning of forcing them to accept it? And if they were forced to accept the Torah, then “this furnishes a strong protest against the Torah,” meaning that the Jews could not be held accountable to its demands until they willingly accepted it in “the days of Ahashverosh.” If so, under what pretext were the Jews punished with exile? And finally, what was so significant “in the days of Ahashverosh” that only then did acceptance of the Torah take place?
Regarding the question as to the necessity to exert coercion after the altruistic expression of acceptance, Maharsha (on Shabbat 88a) emphasizes that the naaseh v’nishmah declaration was not one of “complete acceptance”, for that is something which can only be effected by an actual covenant and oath. Tosafot (ibid.) explain that it was necessary for God to force their “complete acceptance” lest they reconsider their preliminary assent upon seeing “the great fire that drew out their souls.” Hatam Sofer (ibid.) explains that “the fire” they saw was symbolic of the severe punishments for committing violations of the law.
Thus, the coercion employed by God absolved Israel of all Torah demands, and only in the days of Ahashverosh, when they completely accepted the Torah, were they then held accountable for their deeds. The question is then: how the Jews were punished with exile to Babylon if they were not yet accountable? Tosafot (ibid.) implies that though they were indeed not held accountable for the whole Torah, they were held accountable for the one prohibition of idol worship when they entered in to the covenant with Yehoshua, “Far be it from us to forsake the Lord to serve other gods.” (Yehoshua 24:16)
Ritva (ibid.) asks, if it wasn’t until the times of Yehoshua that they accepted the prohibition of idol worship, how was it that they were punished for the idol worship of the golden calf? I suggest that declaration naaseh v’nishmah made them accountable at the very least to worship God exclusively. For though we explained that naaseh v’nishmah was not a “complete acceptance” of the Torah, the Gemara (Shabbat 88a) teaches that it is an angelic expression of selfless unconditional acceptance of God’s authority. Integrity demands that the people’s act of idol worship - i.e., their explicit rejection of the authority they willingly accepted - made them culpable of Divine consequences.
To summarize: Israel accepted God’s authority and were then compelled to accept His whole Torah, for which they were only held accountable for infidelity, their complete accountability remaining contingent on their volitional acceptance.
This explanation of the Gemara is consistent with the text of the Torah when we view the nation of Israel as an individual going through the emotional developmental stages to maturation. The Midrash Tanhuma (Vet'chanan 826) refers to the Jews in Egypt as “a fetus in the womb” that God delivered. They were “born”, as it were, upon 
We view the nation of Israel as an individual going through the emotional developmental stages to maturation.
their exodus from Egypt, passing through the “birth canal” of the Red Sea. As such, the Jews in the desert can be likened to children in respect to their relationship with God and His Torah. They were “spoon fed” like babies from their Father in Heaven through His daily ration of manna. At any difficulty they experienced they simply cried and were immediately answered.

We view the nation of Israel as an individual going through the emotional developmental stages to maturation.

When children are developing, they need definitions of appropriate behavior, boundaries of acceptable action, education of right and wrong - in short, a system of morality. If children are allowed to choose of their own free will, they will choose self-gratification, they will choose based on what “looks good, feels good, tastes good.” Only when one has an appreciation of oneself and the world around - something referred to as “maturity” - can one then begin, of one’s own free will, to accept things that are not associated with self-gratification.
Jewish law and lore acknowledge the staged development of man. Jewish lore explains that until the age of maturity man has only a yetzer hara, a selfish will; and only upon reaching the age of maturity does one acquire a yetzer hatov, a selfless will. Jewish law expresses this idea by exempting minors of culpability for any violation of the Torah. Nevertheless, both parent and teacher do demand absolute obedience to their authority, and it is to this one violation that the child can and must be disciplined. To not do so would be to abandon the child, as King Solomon wrote, “He who spares the rod hates his son, but he who loves him corrects him.” (Proverbs 13:24)
So just as children have to be forced to accept a system of morality, so too did the Jews have to be forced to accept the Torah. And like a child who naturally accepts the authority of his parents, so too did the Jews accept God’s authority - through naaseh v’nishmah. And like a minor, though he cannot be held “legally” accountable for his violations, is nevertheless accountable for obedience to his parents, so too the Jews. Though not punishable for violation of all the various demands of the Torah, they were nevertheless liable to punishment for infidelity - otherwise known as idol worship.
Upon reaching maturity, one becomes responsible for one’s actions, which are then punishable in a court of law. The Jews reached such maturity “in the days of Ahashverosh.” Why? The “days of Ahashverosh” are those recorded in the Book of Esther, which is the only book of the Bible in which the name of God does not appear. Until that time, the Jews always had God’s immediate presence and revealed response available to them. In the days of Ahashverosh, the Jews had no recourse to supernatural exchanges; consequently, they had to assume responsibility for themselves. They had matured to the point where they would now have to solve their problems 
When the Jews took action within the political realm and at the same time fasted and prayed, they acted like mature adults.
through their own devices.

When the Jews took action within the political realm and at the same time fasted and prayed, they acted like mature adults.

This does not mean that they did not rely on God for his behind-the-scenes support, but it does mean that they realized they would have to do everything humanly possible to solve their dilemma, to save their existence. It was this combination of human effort coupled with faith in Divine support that is the message of the Book of Esther. When the Jews took action within the political realm and at the same time fasted and prayed, they acted like mature adults who actively accepted God’s system of Torah and mitzvot. And though this took place during a time of crisis, after the dust settled from their miraculous victory, they formally accepted the Torah without fearing for their lives.
In conclusion, though free will is a fundamental principle of our existence, its proper expression is something to be achieved through mature development. To permit the free exercise of a child’s will without proper inculcation of moral values - through coercion - will result in wayward youth and corrupt adults. And just as it is essential for the individual to follow the developmental stages of: (a) acceptance of authority, (b) education through a compulsory system of values, and (c) free will acceptance, so too was this true for the nation of Israel.