Let’s see what I can do. First of all, the energy of a system depends on the frame of reference you’re measuring it in. For instance, if I’m in an airplane, and the flight attendant walks down the aisle next to me, I would measure a fairly small kinetic energy for em (perhaps 50 Joules or so, since the attendant probably masses about 50 kg, and is travelling at perhaps 1 meter per second relative to me). But if I’m standing on the ground and measure that same flight attendant, I’ll use a speed relative to me of several hundred meters per second, and therefore measure a much higher speed for that flight attendant. All the other forms of energy the flight attendant has don’t depend on frame of reference, so the total energy of the flight attendent is greater in the ground reference frame than in the airplane reference frame.
However, most systems will have some minimum amount of energy, such that, no matter what frame of reference you’re using, you’ll never measure less than that amount of energy. If you’re in a frame such that the system you’re looking at has no net momentum, this is the amount of energy you’ll measure. If, for instance, I’m sitting on the beverage cart, then relative to me, the flight attendent isn’t moving, so I won’t measure any kinetic energy. The only energy I’ll measure is from things like the binding energies of subatomic particles (which, incidentally, is far greater than the kinetic energy, for most objects you’ll encounter). It’s this minimum amount of energy, that you never lose no matter what reference frame you go to, that’s referred to as the mass of the system.
Now, not everything has a mass. If a photon is zipping past me, I’ll measure some energy for it, but if I start moving in the same direction as the photon, I’ll measure a lower energy. The faster I go in that direction, the lower the energy I’ll measure for the photon, and if I can go fast enough, I can make the photon’s energy as low as I want. Since a photon has no minimum energy, we say that an individual photon is massless.
However, suppose I have a system of two photons, going in different directions. I can move in the same direction as one photon, and that photon’s energy will then be less, but when I do that, I’ll also find that the other photon’s energy is greater than it was. I can’t make the total energy go arbitrarily low, since there will always be at least a certain amount of energy in one photon or the other. This system now does have a reference frame where the energy is as low as it can possibly be, and that amount of energy is the mass of the system.