Differentiating $x^2y$ would account for the $2xy\hspace{2px}dx$ and $x^2\hspace{1px}dy$ terms in the equation.
Differentiating $y^3/3$ would account for the $y^2\hspace{1px}dy$ term at the end of the equation.
That leaves two terms unaccounted for, which very conveniently happen to be $x^2y\hspace{2px}dx$ and $y^3/3\hspace{2px}dx$.

Hence letting $u = x^2y + y^3/3$ gives $u\hspace{2px}dx + du = 0$, which can be solved by using $e^x\!$ as an integrating factor.
That means the original equation becomes exact if $e^x\!$ is used as an integrating factor,
and integrating it will then give $ue^x= (x^2y + y^3/3)e^x\,=$ constant.