Photosynthesis is the process by which plants use sunlight to convert carbon dioxide into sugar. Other organic compounds are made, but generally, we are worried about the production of carbohydrates.
The chemical specifics of photosynthesis are a bit too detailed for this discussion, but they can be boiled down to a couple of important concepts.
First, it allows the use of sunlight to produce chemical potential energy in the form of sugar. Carbon dioxide, in terms of biology, has effectively zero potential energy, and it is useless for an organism to try to metabolize this substance. However, with plant organelles, carbon dioxide can be combined with other molecules of carbon dioxide and water, making energy-containing bonds. These bonds are then broken to produce the energy that powers almost all life in anabolic reactions. Therefore, when we consider the flow of energy in living systems, we see that energy produced in the sun flows to plants and other photosynthetic organisms, which create sugar and allow energy to flow to other organisms.
The second important concept is that this process keeps carbon from being wasted. Carbon is the basis for every biological macromolecule, just as it is the basis to make fuel for every living thing on this planet! It is not a resource that can be wasted in large amounts, and photosynthesis allows the carbon that has been used to produce energy to be converted into a usable form. The carbon that has been used for energy is generally in the form of carbon dioxide, which, as we mentioned before, is converted to sugar. This sugar can then be metabolized by an organism to produce carbon dioxide, and the cycle repeats anew. Similarly, molecular oxygen is produced during photosynthesis, and this fuel is important to the many aerobic organisms, like you and me, to be recycled as it is used.
I hope this provides a good overview of the process as it relates to your question!