What do we want of a physical theory? Newton told us of gravity and how to calculate forces and predict their effect on the motion of point masses. He took as given the traditional notion of location and introduced derivatives to elucidate notions of velocity.
Notions of energy were defined in Newtonian terms even though Newton made little use of energy.
The Hamiltonian is more abstract. It posits energy and invites us to define how energy depends on the properties of the system that we would study. Quantum mechanics employs Hamiltonians and likewise challenges us to define the Hamiltonian in terms that we can relate to measurements.
As far as I can see this is an art in both cases. For classical physics we use our notions of energy to guess the Hamiltonian for a system. Our notions of energy came to us via Newton and perhaps Leibniz.