It's definitely a case of function over form. The folds are probably what most people notice first when they look at the brain. For some it may be a little off-putting and for others intriguing, but there is no doubt in it's value.
To understand the folds we need to revisit the Cortex, the outer layer of the brain. That's where most of the actual 'thinking' takes place in our brains. The cortex is only on the surface and only about 3.4mm thick. So to maximize the amount of surface area in a relatively fixed space, we've evolved brains whose surface is folded.
In fact if we unfolded the cortex of our brains it would stretch out to 2.5 square feet or 0.23 square meters.
It's the same principle that's involved in making machine or car radiators. If you look through them you'll notice that many of them have fins that go up and down like waves. This means that more material is exposed to the cooling air that passes over them. The goal of both the wavy fins of radiators and our brain folds are the same, to increase the available surface area.
Human brain folds are a highly evolved trait. Only mammals have evolved this ability and amongst them only cats, dogs, monkeys, dolphins and humans. Other animals and mammals like rats are still have their 'primitive' flat, unfolded brains.