Do something with really good results / extra good.
The sugar represents the "little extra" on top of something, like coffee for instance. The sugar makes it extra good. You can have the coffee black, but you prefer it with sugar.
You can also say "...cherry on top"
The cherry is on the top of a bowl of ice cream with whipped cream or on top of a muffin. The muffin/the ice cream will be/look/taste extra special/good with a cherry on top, which is where it got it's meaning. So the cherry represents the "little extra" the muffin/ice cream needs.
"So pretty please, with sugar on top; clean the fucking car"
-Winston 'The Wolf' Wolfe in the movie Pulp Fiction (1994)