In case you're still looking for more information on this, I'll chip in my two cents.
It may help to think of neural networks as just fitting some function based on the training data. Each hidden layer increases the ability of the neural network to fit more complex functions. A network without hidden layers, often called a perceptron, is only able to fit linear (technically linearly separable) functions. As a rule of thumb, each hidden layer adds the ability to fit one higher degree polynomial function. So for example a network with one hidden layer should be able to fit a quadratic function, two hidden layers can fit a cubic function and so on.
Perhaps contrary to your intuition, the cosine you're trying to train is actually a complex dataset for a neural network, precisely because it fits polynomial functions. Implicitly the network will relax to weights that are in principle approximating your cosine with a polynomial. If you look at the tailor expansion for a sine for example, you'll see that a close approximation would require a 7th degree polynomial, which together with the rather small $\frac{1}{7 !}$ weight should prove quite a challenge for your network to train.
It might also be interesting to note that the approximation only holds well for $−1 < x < 1$, since a typical polynomial will quickly diverge from the sine/cosine beyond this interval. You might want to take that into account for your training set.
To wrap up it up, the primary reason you should be cautious with just adding hidden layers is the problem of overfitting. If you add too many layers (ie more layers than would be required for the -possibly unknown- polynomial underlying your training data), the network will typically fit too tightly to your training dataset, making it less useful for interpolation or extrapolation, or just evaluating new data outside the set.
A good example would actually be that tailor expansion again. If you read on in that section you'll come across the note that higher degree polynomials only marginally improve the accuracy in $−1 < x < 1$, while they perform (much) worse outside this interval. I should note that this may not exactly be the same problem, but it does illustrate what could go wrong.