I am not sure if I understood right- but I'll try to explain.
Example: Person A and person B
I think a person (A) can say "how sweet it is" when another person(B) laughed at person A for experiencing something bad, but then the person(B) who laughed gets it too, so this person learns a lesson. And person A says: How sweet it is.
The phrase was made popular by "The Honeymooners" a TV series from the 50´s with Jackie Gleason. He would say "how sweet it is!" whenever something good, convenient and unexpected took place. Like let´s say you win the lottery, so you say "How sweet it is!".
Then, later on Marvin Gaye came out with the song How sweet it is (to be loved by you).
It has the same meaning as "Life is sweet".