From Feynman's lectures

Interesting note: The integral is a minimum if a velocity is constant (when there are no forces). If you deviate from the mean velocity too much, the mean square of that is always greater than the square of the mean. However, when we throw the ball upwards, it rises fast and then slows down. This is because we also incorporate the potential energy. You can't go up too fast because you will have too much kinetic energy. The solution is a balance between trying to get more potential energy with the least amount of extra kinetic energy.

Action=S=t1t2(KE – PE) dt=[m2(dxdt)2V(x)]dt

Calculus of variations -> we can't just take the derivative and set it equal to zero because it's a path, not a variable.

The "True Path" taken by a particle is the one where the Action (S) is at a minimum. Therefore, if you take the True Path and distort it slightly (a first-order variation), the value of the Action should not change (to a first-order approximation). This is equivalent to setting the first derivative (or variation) to zero.

We call x(t) the true path that we are trying to find. We take some trial path x(t) that differs from the true path by a small amount which we will call η(t). If we calculate the action S for the path x(t), the difference between S and the action we calculated for x(t) must be 0 in the first order (the difference in the second order can be nonzero).
Apply boundary conditions: η(t1) and η(t2)=0 because these must be fixed, we must not deviate from the true path.

x(t)=x(t)+η(t)S=t1t2[m2(dxdt+dηdt)2V(x+η)]dt==t1t2[m2((dxdt)2+2dxdtdηdt+(dηdt)2)V(x+η)]dt

Ignore the second order η parts. As for the potential energy, we can expand it as Taylor series:

V(x+η)=V(x)+ηV(x)+η22V(x)+...$$andignorethesecondorder$η$parts.$$S=t1t2[m2(dxdt)2V(x)+mdxdtdηdtηV(x)+O(η2)]dt

The first two terms correspond to the action of S. Let δS (variation in S) be the difference between S and S, which corresponds to the other two terms. Leaving out the second and higher order terms as well, we get:

δS=t1t2[mdxdtdηdtηV(x)]dt

Using integration by parts, we can write the variational derivative as:

δS=mdxdtη(t)|t1t2t1t2ddt(mdxdt)η(t)dtt1t2V(x)η(t)dt

The first term disappears because η(t1)=0 and η(t2)=0.

δS=t1t2[md2xdt2V(x)]η(t)dt

If the action integral is zero for any η, then the coefficient of η must be zero. The action integral will be a minimum for th epath that satisfies $$\left[-m \frac{d^2\underline x}{dt^2} - V'(\underline x) \right] = 0$$
This is just F=ma. Derivative of the potential energy is force. The principle of least action says that the path that has the minimum action is the one satisfying the Newton's law.