Here's a motivation for where the inertia tensor $I=(I_{ij})$ (and by extension moments of inertia) comes from. It's a quantity that's analogous to mass for rotational motion in the sense that the kinetic energy of a rotating object is essentially proportional to the inertia tensor times the square of the body's angular velocity. More precisely \begin{align} T(t) = \frac{1}{2} \boldsymbol \omega(t)^tI(t)\boldsymbol \omega(t). \tag{1} \end{align} where $\boldsymbol \omega(t)$ is the instantaneous angular velocity of the body. Compare this, for example, to the expression for the kinetic energy of a particle of mass $m$ moving with speed $v$; \begin{align} T = \frac{1}{2}mv^2. \end{align}
To prove expression $(1)$, start with a rigid body consisting of points $\mathbf x_i$ undergoing pure rotation. There exists a time-dependent rotation $R(t)$ that generates the motion of all points in the rigid body; \begin{align} \mathbf x_i(t) = R(t)\mathbf x_i(0) \tag{2} \end{align} The kinetic energy of the body is the sum of the kinetic energies of the individual particles; \begin{align} T(t) &= \frac{1}{2}\sum_i m_i \dot{\mathbf x}_i(t)\cdot\dot{\mathbf x}_i(t) \\ &= \frac{1}{2}\sum_i m_i \big(\dot R(t)\mathbf x_i(0)\big)\cdot\big(\dot R(t)\mathbf x_i(0)\big) \\ &=\frac{1}{2}\sum_i m_i \big(\dot R(t)R(t)^t\mathbf x_i(t)\big)\cdot\big(\dot R(t)R(t)^t\mathbf x_i(t)\big) \\ \end{align} where in the last equality I used the fact that $R^tR = I$ for rotations so that eq. $(2)$ gives $\mathbf x_i(0) = R(t)^t \mathbf x_i(t)$. Now, we note that \begin{align} \dot R(t)R(t)^t\mathbf x_i(t) = \boldsymbol\omega(t)\times\mathbf x_i(t) \end{align} where $\boldsymbol\omega$ is the angular velocity vector of the body. See the following for a detailed derivation of this fact:
Angular Velocity expressed via Euler AnglesAngular Velocity expressed via Euler Angles
So putting this together, we have \begin{align} T(t) &= \frac{1}{2}\sum_im_i\big(\boldsymbol\omega(t)\times \mathbf x_i(t)\big)\cdot \big(\boldsymbol\omega(t)\times \mathbf x_i(t)\big) \\ &= \frac{1}{2}\sum_im_i \sum_{j,k}\omega_j\big(\mathbf x_i^2\delta_{jk} - (x_i)_j(x_i)_k\big)\omega_k \\ &= \frac{1}{2} \sum_{j,k}\omega_j\left[\sum_im_i\big(\mathbf x_i^2\delta_{jk} - (x_i)_j(x_i)_k\big)\right]\omega_k \\ \end{align} Now, if we simply note that the inertia tensor is defined as the quantity whose components $I_{jk}$ are in the big brackets, then we have the desired formula.
Note, in particular, that when $j=k$, namely when we consider only the diagonal components of the inertia tensor, then we obtain the $j$th moment of inertia \begin{align} I_{jj} = \sum_i m_i\big(\mathbf x_i^2 - (x_i)_j^2\big) \end{align} so, for example, the $x$ moment is \begin{align} I_{xx} = \sum_i m_i(y_i^2+z_i^2) \end{align} and if the object is in the $x$-$y$ plane, then $z=0$ and we get \begin{align} I_{xx} = \sum_i m_i y_i^2 \end{align} and if the body is continuous, then sums get replaced with the appropriate integrals; \begin{align} m_i\to dm, \qquad I_{xx}\to \int y^2 dm \end{align}