Energy is a many-faced item. It started out as a kind of curiosity in Newtonian mechanics: In certain specific cases (namely those where the forces were conservative, or derivable from a potential function), one could write a function of the mechanical configuration ("potential energy") and a function of the velocities ("kinetic energy"), and it turned out that the sum of both was conserved through time.
In Newtonian mechanics as such, this didn't need to be: one can introduce forces (friction forces) such that this trick doesn't work. But in the case of conservative forces, it was nice to have this "energy" trick which allowed to solve problems (especially together with "momentum conservation", which followed from Newton's action=reaction principle).
People reformulated Newtonian mechanics for the specific case that all forces were conservative and out of that came an entire body of theoretical work, which was Lagrangian and Hamiltonian mechanics. It is a beautiful framework, and assumes from the start that "energy is conserved". (ok, nitpickers will tell me that there are extensions to Lagrangian mechanics which allow dissipation functions, true...)
Now, what turned out to be a "limiting hypothesis" in the beginning, namely that we had to limit ourselves to conservative forces, showed up to be of great interest. Indeed, in the Hamiltonian formulation of mechanics, it turns out that this quantity, energy, plays a fundamental role as generator of time translations. It's a bit difficult to explain this here, but if a system possesses a certain continuous symmetry, then there is a "generator of the symmetry", which indicates how the system transforms under said symmetry operation. In an abstract way, one can think of a "time translation" also as a symmetry operation on the system, and it turns out that the corresponding generator is nothing else but "energy".
In a similar way, space translations correspond to a generator which is nothing else but momentum.
It also turns out that all fundamental interactions we know about, are conservative. This gives a special importance to the Lagrangian and Hamiltonian formulations, and hence, energy.
Comes in (special) relativity. In special relativity, it turns out that the 4-th component one has to add to the 3-momentum (the ordinary Newtonian momentum which was already postulated to be conserved, through the action-reaction principle) to make a good 4-vector, is nothing else but, again, energy. Given that, under Lorentz transformations, the 4-th component (the "time" component) mixes with the 3-vector (the "space" component) of a 4-vector, momentum cannot be conserved if energy is not conserved. So if we took (since Newton's time) momentum as conserved, and we accept relativity, this automatically means that energy is conserved - which is also an explanation for the fact that all fundamental interactions are conservative... and which confirms the importance of the Lagrangian formulation of mechanics.
From a totally different side came thermodynamics. The first law of thermodynamics states that there is a conserved state function, and this is recognized, in statistical mechanics, as, again, the total energy of the system. We now also understand the "non-conservative" forces we originally considered in Newtonian mechanics: they correspond simply to the transformation of macroscopic mechanical energy into microscopic mechanical energy. We only saw the "energy dissipate" because we forgot to take into account the microscopic degrees of freedom ; we can restore this by incorporating "heat" in the balance.
We thus see that the concept of energy grew in importance over the course of physics history:
from a curiosity in Newtonian mechanics, it:
- became a pillar in the Lagrangian and Hamiltonian formulation
- became the generator of time translations
- became the 4-th component of momentum in relativity
- became the state function in the first law of thermodynamics