The particles (atoms and molecules) that make up a substance are always moving, and they also have energy because of the forces between them. Energy is stored inside a system by its particles. This store is called internal energy.
Internal energy is the total kinetic energy and potential energy of all the particles in the system. The kinetic part comes from the movement of the particles. The potential part comes from the positions of the particles relative to each other, which depends on the forces between them.
Heating a system increases the energy of its particles. There are two possible results. Either the temperature of the system rises, or the substance changes state, for example from solid to liquid. In a change of state the extra energy goes into the potential energy of the particles as they move away from each other.
Notice that internal energy is the energy of all the particles added together. A bath of water at 40 °C has far more internal energy than a cup of water at 40 °C, because it contains many more particles.