Why did life decide to use carbon?
Do you remember the periodic table? There are about 118 elements over there, but the human body is made 97% by only six elements: hydrogen, oxygen, nitrogen, sulfur, phosphorus and carbon.
Carbo-hydrates are made of CARBON and H20. Why pick carbon as an energy source? There are elements that are much more abundant and easier to find on Earth.
The "king of the elements"
Carbon is stable and flexible at the same time, a compound stable enough to not fall apart during digestion and flexible enough to create very long chains. It is like a perfect "marriage material" because he loves bonding. He has four electrons in his outer shell. If another element wants his electrons, he has to bond with the carbon and "take him as a full package".
Carbohydrates are there to give you energy
If you haven´t seen the video about each macronutrients´ purpose, take a look over here.
In summary, each nutrient has its own main function. Fat is mainly used as storage, proteins are used for structure (enzymes, mass, hormones, immune system)... and carbohydrates give you energy. They are like the fire burning in your house (your body).
Why are there good carbs and bad carbs?
Let us all agree that there aren´t really good or bad foods out there. There are nutrients that under certain circumstances are less valuable and more harmful than others. In this case, simple carbs are considered less healthy than complex carbs.