Why should an action integral be stationary? On what basis did Hamilton state this principle? Hamilton's principle states that a dynamic system always follows a path such that its action integral is stationary (that is, maximum or minimum).
Why should the action integral be stationary? On what basis did Hamilton state this principle?
 A: As you can see from the image below, you want the variation of the action integral to be a minimum, therefore $\displaystyle \frac{\delta S}{\delta q}$ must be $0$. Otherwise, you are not taking the true path between $q_{t_{1}}$ and $q_{t_{2}}$ but a slightly longer path. However, even following $\delta S=0$, as you know, you might end up with another extremum.

Following the link from j.c., you can find On a General Method on Dynamics, which probably answers your question regarding Hamilton's reasoning. I haven't read it but almost surely it is worthwhile.
A: I generally tell the story that the action principle is another way of getting at the same differential equations -- so at the level of mechanics, the two are equivalent.  However, when it comes to quantum field theory, the description in terms of path integrals over the exponentiated action is essential when considering instanton effects.  So eventually one finds that the formulation in terms of actions is more fundamental, and more physically sound.
But still, people don't have a "feel" for action the way they have a feel for energy.
A: Let us remember that the equations of motion with initial conditions $q(0), (dq/dt)(0)$ were advanced first and the least action principle was formulated later, as a sequence. Although beautiful and elegant mathematically, the least action principle uses some future, "boundary" condition $q(t_2)$, which is unknown physically. There is no least action principle operating only with the initial conditions.
Moreover, it is implied that the equations have physical solutions. This is so in the Classical Mechanics but is wrong in the Classical Electrodynamics. So, even derived from formally correct "principle", the equations may be wrong on physical and mathematical level. In this respect, formulating the right physical equations is a more fundamental task for physicists than relying on some "principle" of obtaining equations "automatically". It is we physicists who are responsible for correctly formulating equations.
In CED, QED, and QFT one has to "repair on go" the wrong solutions just because the physics was guessed and initially implemented incorrectly.
P.S. I would like to show how in reality the system "chooses" its trajectory: if at $t = 0$ the particle has a momentum $p(t)$, then at the next time $t+dt$ it has the momentum $p(t) + F(t)\cdot dt$. This increment is quite local in time, it is determined by the present force value $F(t)$ so no future "boundary" condition can determine it. The trajectory is not "chosen" from virtual ones; it is "drawn" by the instant values of force, coordinate, and velocity.
A: Instead of specifying the initial position and momentum just like we have done in Newton's formalism, let’s reformulate our question as following:

If we choose to specify the initial and final positions: $\textbf{What path does the particle take?}$


Let's assert we can recover the Newton's formalism by the following formalism, so-called Lagrangian formalism or Hamiltonian principle.
To each path illstrated on above figure, we assign a number which we call the action 

$$S[\vec{r}(t)] = \int_{t_1}^{t_2}dt \left(\dfrac{1}{2}m\dot{\vec{r}}^2-V(\vec{r})\right)$$

where this integrand is the difference between the kinetic energy and the potential energy.

$\textbf{Hamilton's principle claims}$: The true path taken by the particle is an extremum of S.

$\textbf{Proof:}$
1.Change the path slightly:
$$\vec{r}(t) \rightarrow \vec{r}(t) +\delta \vec{r}(t)$$
2.Keep the end points of the path fixed:
$$ \delta \vec{r}(t_1) = \delta \vec{r}(t_2) = 0 $$
3.Take the variation of the action $S$:

finally, you will get 
$$ \delta S = \int_{t_1}^{t_2} \left[-m\ddot{\vec{r}} - \nabla V\right] \cdot \delta \vec{r} $$
The condition that the path we started with is an extremum of the
action is
$$\delta S = 0$$
which should hold for all changes $\delta \vec{r}(t)$ that we make to the path.The only way this can happen is if the expression in $[\cdots]$ is zero. This means

$$ m\ddot{\vec{r}} = -\nabla V$$

Now we recognize this as $\textbf{Newton’s equations}$. Requiring that the action is extremized is equivalent to requiring that the path obeys Newton’s
equations.
For more details you could read this pdf lecture.
Hope it helps.
A: The notes from week 1 of John Baez's course in Lagrangian mechanics give some insight into the motivations for action principles.
The idea is that least action might be considered an extension of the principle of virtual work.  When an object is in equilibrium, it takes zero work to make an arbitrary small displacement on it, i. e. the dot product of any small displacement vector and the force is zero (in this case because the force itself is zero).
When an object is accelerating, if we add in an "inertial force" equal to $\,-ma\,$, then a small, arbitrary, time-dependent displacement from the objects true trajectory would again have zero dot product with $\,F-ma,\,$ the true force and inertial force added.   This gives
$$(F-ma)\cdot \delta q(t) = 0$$
From there, a few calculations found in the notes lead to the stationary action integral.
Baez discusses D'Alembert more than Hamilton, but either way it's an interesting look into the origins of the idea.
A: There is also Feynman's approach, i.e. least action is true classically just because it is true quantum mechanically, and classical physics is best considered as an approximation to the underlying quantum approach.   See Feynman's Thesis — A New Approach to Quantum Theory  or A call to action, by Edwin F. Taylor.
Basically, the whole thing is summarized in a nutshell in
Richard P. Feynman, The Feynman Lectures on Physics (Addison–Wesley, Reading, MA, 1964), Vol. II, Chap. 19. (I think, please correct me if I'm wrong here).  The fundamental idea is that the action integral defines the quantum mechanical amplitude for the position of the particle, and the amplitude is stable to interference effects (-->has nonzero probability of occurrence) only at extrema or saddle points of the action integral.   The particle really does explore all alternative paths probabilistically.
You likely want to read Feynman's Lectures on Physics anyway, so you might as well start now.  :-)
A: It is possible in classical physics to derive the Euler-Lagrange equations from D'Alembert principle, without any reference to the notion of action. They come from Newton's laws with the additional assumption that the forces are conservative. In this case there is a Lagrangian, and the equation of movement (EOM) is the Euler-Lagrange equation.
Suppose that a function q(t) is a solution for the EOM in a certain interval. q can be expanded as a Taylor series, that is a power series: $q(t) = \sum_j a_jt^j$.
The action is: $S(L) = \int_{t1}^{t2} Ldt$ where L is the Lagrangian that corresponds to the EOM. Because the integral is in $t$, and we are taking the derivative with respect to the coeficients $a_j$, it can go inside the integral. For each $a_j$.
$$\frac{\partial S}{\partial a_j} = \int_{t1}^{t2} \frac{\partial L}{\partial a_j}dt$$
L is a function of $q$ and $\dot q$, so applying the chain rule:
$$\frac{\partial L}{\partial a_j} = \frac{\partial L}{\partial q}\frac{\partial q}{\partial a_j} + \frac{\partial L}{\partial \dot q}\frac{\partial \dot q}{\partial a_j}$$
Integrating this differential between 2 instants of time:
$$\int_{t1}^{t2}\frac{\partial L}{\partial a_j}dt = \int_{t1}^{t2}\frac{\partial L}{\partial q}\frac{\partial q}{\partial a_j}dt + \int_{t1}^{t2}\frac{\partial L}{\partial \dot q}\frac{\partial \dot q}{\partial a_j}dt $$
The last term can be separated using integral by parts, using that differentiating with respect to time: $d\left (\frac{\partial q}{\partial a_j}\right ) = \frac{\partial \dot q}{\partial a_j} dt$:
$$\int_{t1}^{t2}\frac{\partial L}{\partial \dot q}\frac{\partial \dot q}{\partial a_j}dt = \frac{\partial L}{\partial \dot q}\frac{\partial q}{\partial a_j}\bigg|_{t1}^{t2} - \int_{t1}^{t2}\frac {\partial  \frac {\partial L}{\partial \dot q}}{\partial t} \frac{\partial q}{\partial a_j}dt$$
So:
$$\int_{t1}^{t2}\frac{\partial L}{\partial a_j}dt = \int_{t1}^{t2}\frac{\partial L}{\partial q}\frac{\partial q}{\partial a_j}dt - \int_{t1}^{t2}\frac {\partial  \frac {\partial L}{\partial \dot q}}{\partial t} \frac{\partial q}{\partial a_j}dt + \frac{\partial L}{\partial \dot q}\frac{\partial q}{\partial a_j}\bigg|_{t1}^{t2}  $$
Joining the integrals, we get between parentheses the Euler-Lagrange equation, that is the EOM itself! If q is solution by hypothesis, this integral must be zero.
$$\int_{t1}^{t2}\frac{\partial L}{\partial a_j}dt = \int_{t1}^{t2}\left (\frac{\partial L}{\partial q} - \frac {\partial  \frac {\partial L}{\partial \dot q}}{\partial t} \right) \frac{\partial q}{\partial a_j}dt + \frac{\partial L}{\partial \dot q}\frac{\partial q}{\partial a_j}\bigg|_{t1}^{t2}  $$
For the last term, the second order integral needs 2 boundary conditions. If $q(t_1)$ and $q(t_2)$ are known, they are fixed and $\frac{\partial q}{\partial a_j}\bigg|_{t1} = \frac{\partial q}{\partial a_j}\bigg|_{t2} = 0 \implies$ this term vanishes.
Now, we get to the conclusion that the derivative of the action with respect to all coeficients must be zero in the interval, what is the same as to say that the action must be stationary.
