While complex carbohydrates are essential for our bodily functions, simple carbohydrates (such as sugar) most certainly are not. When you eat sugar (and indeed when you eat any other refined carbohydrate albeit to a lesser extent) your insulin levels spike and this is what causes you to store fat. You see, your body can use sugar for energy extremely quickly as there is literally no conversion process required to turn it into glucose and so your cells get filled with more glucose than they need to perform their function, and when cells have excess glucose the remainder gets stored as fat.
Here's a great simplified illustration from the movie Fed Up that shows how it works:
Complex carbohydrates are essential because there are certain organs that can only function on energy from glucose (the brain, kidney and testes). However, that does not mean to say that you need to get your carbohydrates from grains. Vegetables contain carbohydrates for example and are a much healthier source than grains as they’re typically much higher in fibre and other essential nutrients such as vitamins. Grains are generally discouraged because they can prevent mineral absorption (because of phytates which bind to the minerals) and cause inflammation (because of gluten and celiac disease but gluten has even been shown to cause weight gain in those without sensitivity to gluten).
Another good reason to get your carbs from mostly vegetable sources is because it also helps to protect your bone health by preventing your body from becoming overly acidic. The US consumes more calcium than any other country and yet has the highest rate of bone disease. You'd think the opposite would be true, but when there is an excessive consumption of sugar and carbohydrates the body becomes acidic and calcium is drawn from the bones to neutralize the pH.