The idea of Ostrogradsky is to answer what if equation of motion is not of second time derivative but with higher derivatives. Using variational principle such situation can be made when Lagrangian is non-degenerate at higher derivatives i.e. $\frac{\partial^{2} L}{\partial x^{(n)^{2}}} \ne 0$ where $x^{(n)}$ is $n$ number of time derivatives.