As others have pointed out, the question is somewhat misworded.
The correct question is probably just "Why do magnets repel?", which can be traced back to the question of why electromagnetism (EM) is a fundamental force of nature. Like gravity, it's one of the four known fundamental forces of nature.
Regarding the use of the word "energy". Energy is the same thing as work. Work = Force x distance. If there is a 10N [Newton] force acting on a ball, and you move the ball by 1m [meter], you have done 10N x 1M = 10Nn = 10J [Joule] of work (provided the force is constant). So, if you move the magnetic poles against each other, you do work (against the EM field). Then, if you attach the magnets to a spring and let go, the springs will compress. The 10J of work you invested is now stored in the springs! Then, if you remove the magnets and put a bullet on the spring, and let go, you can use the 10J of energy to launch the bullet (work is converted to kinetic energy), and so on =)
What happens when you push two magnets against each other, but then just hold them in place? Per the above definition of Work = Force x distance, you're not doing work, because distance = 0. But clearly your muscles are straining, and you're burning calories (which is just another unit of energy or work, like Joules), so what's going on? From a physics textbook point of view, no work is being done. This is similar to placing an apple on a table. The table is countering the force of gravity, like your muscles in the magnet example. The table has no muscles, because it is made of wood, and it won't collapse under the weight of the apple. In reality, the stiffness of the table/wood is provided by the electromagentic interactions of the atoms making up the table, so in the end it is the EM force counteracting the gravitational force. In the original magnet/muscle example, your arms are not made up of wood, so your body is doing biochemical/mechanical work to stiffen the cells in your arms by burning the food you ate. (The fact that this process is not perfect means that heat is a by product of this process, that's why your muscles get hot and you start sweating.)