Why are $X \sim U(-1,1)$ and $Y=X^2$ dependent? Suppose we have two continuous random variables $X \sim U(-1,1)$ and $Y=X^2$. I don't understand why they are dependent.
$$E[X] = 0$$
$$E[Y] = \int_{-1}^{1} x^2  dx = 2/3$$
$$E[XY] = \int_{-1}^{1} x^3 dx = 0$$
They are independent to me because $E[XY]=E[X]E[Y]$, so why they are dependent?

You need to distinguish between the concepts of uncorrelatedness, which involves the decomposition of the expectation of a product, and independence, which involves the decomposition of a joint probability distribution. What you're calling independence is actually uncorrelatedness. What happens, as the other answers show, is that independence is a stronger condition than uncorrelatedness, that is, independence implies uncorrelatedness but the vice versa is not true.
And your example is exactly one example that is used to show that uncorrelatedness does not imply independence.
