Why did H'shem have to force the acceptance of the Torah after the people wholeheartedly agreed to it? The Baal Shem Tov, saw the coercion as an important lesson for man.
The children of Israel did indeed accept the Torah of their own free will and no coercion was required for this. But we are all familiar with human nature: good will is something that may disappear. Sometimes a person really wants to do the good and right thing, but sometimes, that same person is preoccupied with problems and difficulties and can’t make the effort to do the right thing. For these times, the Baal Shem Tov says, G-d imposed on the children of Israel the acceptance of the Torah; as if to say – You should know that good will works some of the time, but at other times, you will have to force yourself to make the effort, fighting momentary impulses, in order to follow the straight path.
thekotel.org
"Hashem said that the purpose of the Aseres HaDibros and all mitzvos of the Torah is so people will be able to say and to believe in H'shem. For this is the segulah of the 613 mitzvos; they bring emunah into our hearts.