Very crudely: Lagrangian mechanics leads to second order differential equations, which can be formally solved by knowing the values of the unknown functions at an initial and a final point. In short, if you know where the cannonball starts and where it ends up, Lagrangian mechanics lets you calculate its trajectory, after the fact, so to speak.
Hamiltonian mechanics leads to twice as many first order differential equations, which can be formally solved by knowing the values of the unknown functions at the initial point only. In short, if you know the position and momentum (or velocity) of the cannonball at the initial moment, you can calculate and predict its trajectory.
The relationship between the Lagrangian and Hamiltonian formalism is given by the so-called Legendre transformation. The Legendre transformation is a mapping between a function and its family of tangents. Instead of describing a function as a function of an independent variable yielding the dependent variable, the transformed function yields the intercept value for every given slope (of a tangent). If the original function was convex, it can be fully reconstructed from its Legendre transform, which is its own inverse.
Hamiltonian mechanics is also used as the basis for canonical quantization, via the application of formal rules that are used to replace classical observables with quantum mechanical operators.
The conservation of energy is a consequence of the time translation symmetry of the Lagrangian. More generally, any symmetry of the Lagrangian leads to a conservation law: e.g., spatial translation symmetry leads to momentum conservation, whereas symmetry under spatial rotations leads to the conservation of angular momentum. (The general theorem relating symmetries and conservation laws is Noether’s theorem, named after its discoverer, the early 20th century mathematician Emmy Noether.)