Each molecule of water is made of 2 atoms of hydrogen and 1 atom of oxygen. Sugar can dissolve in water only when its molecules can get some space between two molecules (H2O) of water. This is difficult when water is cold and the molecules of H2O are tightly packed with very little space left between the nearest molecules. Vigorous stirring is required in order to dissolve sugar in cold water. Stirring water with a spoon forces molecules of H2O to scatter. This creates some room between H2O molecules, where sugar molecules fit.
When water is heated, its molecules move farther apart. The space between two molecules becomes larger, allowing molecules of sugar to fill the gaps easily and quickly.