Sugar is one of the items that is produced through photosynthesis.  Oxygen is the other.  The plant produces sugar to live on and the sugar gives the plant energy.