The total energy of the universe consists of the energy due to the motion of all the particles (called kinetic energy), the energy that is stored because of the gravitational forces between the particles (called potential energy), and the energy associated with the mass of all the particles (usually referred to as rest energy).
The key feature to bear in mind is that the gravitational potential energy is a negative quantity. You can see this by realizing that in order to separate two objects, one has to overcome the attractive gravitational force and this requires one to supply positive energy from outside. This is why launching satellites into space requires such huge amounts of positive energy supplied by fuel, in order to overcome the negative gravitational potential energy of the satellite due to the Earth's attractive force.
This negative gravitational potential energy exactly cancels out the positive energy of the universe. As Stephen Hawking says in his book A Brief History of Time (quoted by Victor Stenger, Has Science Found God?, p. 148): "In the case of a universe that is approximately uniform in space, one can show that this negative gravitational energy exactly cancels the positive energy represented by the matter. So the total energy of the universe is zero." In other words, it is not the case that something came out of nothing. It is that we have always had zero energy.
Alan Guth, one of the creators of the inflationary universe model, points out that the fact that "in any closed universe the negative gravitational potential energy cancels the energy of matter exactly" has been known for some time and can be found in standard textbooks. (See The Classical Theory of Fields by L. D. Landau and E. M. Lifshitz, second edition, 1962, p. 378-379.)
But what made the universe and all its mass come into being at all? The suggestion is that the universe began as a quantum fluctuation of the vacuum. It used to be thought that the vacuum was truly nothing, simply inert space. But we now know that it is actually a hive of activity with particle-antiparticle pairs being repeatedly produced out of the vacuum and almost immediately annihilating themselves into nothingness again. The creation of a particle-antiparticle pair out of the vacuum violates the law of conservation of energy but the Heisenberg uncertainty principle allows such violations for a very short time. This phenomenon has observable and measurable consequences, which have been tested and confirmed. (The Inflationary Universe, Alan Guth, 1997, p. 272)