This question already has an answer here:
Why does Quantum Field Theory use usually Lagrangians rather than Hamiltonains?
I heard many reasons, but I'm not sure which is true.
Some say it's just a matter of beauty, so Lagrangians are more beautiful because they don't break/separate the space-time variables (so space-time is a single variable, like in the Klein-Gordon Lagrangian and Hamiltonian).
Some say that Hamiltonians are not always Lorentz invariant.
Could someone explain in a little bit more details?