One solution to this problem would be to use Hilbert space methods. There is a well-known orthogonal basis to $L^2([-1,1])$ given by the Legendre polynmials. Let $P_0,P_1,\ldots$ be the Legendre polynomials, as defined in the Wikipedia link. Your conditions $$\tag{$*$}\int_{-1}^1 g(x)\,dx = 0\mbox{ and }\int_{-1}^1g(x)x^2\,dx = 0$$ are equivalent to the inner product equations $\langle g, P_0\rangle = 0$ and $\langle g, P_2\rangle = 0$. Moreover, it is easy to derive that $x^3 = \frac{2}{5}P_3 + \frac{3}{5}P_1$. If $\hat{P}_1$ and $\hat{P}_3$ denote the normalizations of $P_1$ and $P_2$, then $$\hat{P}_1 = \sqrt{\frac{3}{2}}P_1\mbox{ and }\hat{P}_3 = \sqrt{\frac{7}{2}}P_3,$$ so that $$x^3 = \frac{2}{5}\sqrt{\frac{2}{7}}\hat{P}_3 + \frac{3}{5}\sqrt{\frac{2}{3}}\hat{P}_1.$$ In order for $\langle g, x^3\rangle$ to be maximal, $g$ can therefore only have components in the $P_1$ and $P_3$ directions, i.e., $g = a\hat{P}_1 + b\hat{P}_3$ with $a^2 + b^2 = 1$. We have therefore reduced the problem to maximizing $$\langle g, x^3\rangle = \frac{2}{5}\sqrt{\frac{2}{7}}b + \frac{3}{5}\sqrt{\frac{2}{3}}a$$ under the constraint $a^2 + b^2 = 1$. Standard Lagrange multipliers techniques give that this quantity is maximized when $$a = \frac{3}{5}\sqrt{\frac{7}{3}}\mbox{ and }b = \frac{2}{5},$$ and that for these values of $a$ and $b$ one has $\langle g, x^3\rangle = \sqrt{2/7}.$ Moreover, $g$ is explicitly computed as $$g = a\hat{P}_1 + b\hat{P}_3 = \sqrt{\frac{7}{2}}x^3.$$