Just after the universe started, the only element around was hydrogen. The hydrogen collected together through gravity and became stars. The stars became massive enough that gravity allowed the hydrogen to overcome its electrostatic repulsion for itself and to start undergoing the fusion nuclear reaction, where two hydrogen atoms collide with enough energy to make them combine into helium. Later, the helium fused to become heavier elements. After billions of years, stars had fused hydrogen atoms into lots of heavy elements, forging everything you see around you today, including you.
Now, nuclear reactions are just like chemical reactions in that they are either exothermic, meaning they release energy, or endothermic, meaning that they require energy to go in the first place. The energy required or released in any nuclear reaction can be determined by measuring the Q value of a reaction, which is just the mass difference between final and initial nuclides multiplied by the speed of light squared (E=mc2. This difference is equivalent to a difference in an intrinsic property of all nuclei, the nuclear binding energy. As seen in the figure below, it just so happens that the maximum binding energy per nucleon occurs somewhere near iron, making iron the most stable element in the universe.
Any nuclear reaction that climbs the curve releases energy and those that descend the curve require energy to occur. So, as you can see, if you combine elements that are lighter than iron, you have an exothermic fusion reaction, which releases energy. If you split heavy atoms, you release energy in exothermic fission reactions. You could probably argue that the fate of the universe is just a big chunk of iron floating around. But until then, we have to make energy. Read on.
If it actually takes energy to create atoms above iron, why are there any up there anyway? The answer is that they were created in supernova explosions, where an incredible number of neutrons were released and collided with nuclei, forming heavier and heavier nuclei. Quite possibly, many of these heavy isotopes have never been seen on Earth because they were very unstable and decayed to lighter, more stable isotopes very quickly. In these heavier, stable elements the universe stored a lot of energy, especially in the heaviest ones. One particularly abundant and stable heavy element that has a lot of energy stored in it is uranium. Enter nuclear reactors.
In summary, it seems that the energy of the nucleus is a result of gravity organizing hydrogen and allowing it to tend towards the least energy state. Although this is not an actual origination, it does explain how the energy got into nuclei. Where the mass and energy actually came from is a question for philosophers, preachers, and astrophysicists. Under the assumption that mass and energy can’t be created or destroyed but can only change forms, it is easy to conclude that it has just always been here.