Think of it like this. A child may be told not to touch a stove because it will hurt, but until the child does so, they will not understand at a truly deep level what it means to be burned. When the burn is gone and the hurt passes, the child becomes wiser in their decisions. They will not touch the stove again when its one because it hurts, and that is not a good thing. The book of Job has something to say on this.
Job 28:28
He said to human beings,
'Have respect for me. That will prove you are wise.
Avoid evil. That will show you have understanding.'