There are already many advanced answers here, so I would like to answer this from a more intuitive understanding.
What you are referring to must be this most famous equation:
When a particle has zero mass, its energy must be zero because E = 0 * c^2 = 0. So you are already concluding it right. A photon (
light particle) that has its mass zero, could not have energy.
As many has answered, that E = mc^2 is not a complete formula. It's true, but we won't discuss it mathematically here. It's not really that interesting. But let me first to show its more complete formula, just for the sake of our discussion:
So, beside the usual mc^2 term, we have this new term: (pc)^2. Don't worry about the square to all those terms, it won't affect much to our discussion.
This "p" in the new term is called momentum. But wait, we do know momentum, it's mass times its velocity: mv. There's mass once again, and when it's zero, the momentum should be zero too! Nah, apparently we do NOT really know this momentum, because a photon could have momentum without necessarily having a mass! We back to the same question again: how could that be??
Momentum starts its career as a mathematical formula. We don't know what it is actually, but there's some quantity, in which we defined as: mass times its velocity, that when nature has done its tricks, this quantity stays the same. We may crash two cars, but after the crash, if we calculate the mass of those two cars times their velocities, we would get the same number we calculate before the crash. We may explode a bomb, but after that, if we collect all the debris, and calculate all their mass times their velocity, we would get the same number with the one we calculate before the bomb explode. Whatever we do, we would get this same number of momentum, mass times its velocity.
One of exciting moments in physics is when we get such a revelation moment. This is a such moment. It turns out that momentum is more REAL than mass! How could physicists say that? It's simple, we imagine something like this. When we are hit by a car, we would be bounced.
Then we ask, is there something that could make us bouncing, without actually being hit by a thing such a car? The answer is: YES. And one of that something is photon.We don't actually see a photon, it's just a hypothetical matter. What we know is electromagnetic radiation could excite electrons far away. When we could see stars, that's because the electromagnetic radiation / light from those stars travel a very far distance to reach our eyes, then excite the electrons in our eyes. If we could receive data through our wifi connection, that's because the electromagnetic radiation from the wifi router excites the electrons in our wifi receiver. However when we observe and calculate the behavior of electrons that are being exposed to electromagnetic radiation, they behave in such a way of being hit by something!
We never found this "something", but if we pretend, imagine, guess, whatever, that this something is a momentum, all of our mathematical formulations involving momentum work perfectly well. Hah! Bingo!
We have something that we never found what it is, but it definitely has a momentum, and for the sake of communication, we "pretend" to know it, and give it a name photon. That is why a photon could have energy or momentum.But, is it for real? In physics, we don't really care about if something is real or not.
As long as it agrees with experiment, it could be in the form of whatever it needs to be, we would say it's useful.
In this case, yes, we started with something easier to comprehend: mass. It's easier in a sense that we could see it directly with our own eyes, such a car, and say it has a mass. Then when we watch nature does its trick, through its mathematical formulation of course, we see quantity that we never actually see such these energy and momentum. We may wonder, is it real or just some result of a mathematical trick? But along with the progress of our understanding to the nature itself, we start to see some behaviors similar to these energy and momentum, without having something we could perceive directly. That makes us ask again, which are more real, energy and momentum, or mass? However as the experiment shows that energy and momentum always exist, where the mass is not necessarily so, we have to accept the fact, no matter how weird it is, that energy and momentum, somehow, are more real than mass.
So the fact that photon could have energy and momentum, without having a mass, is something that we just have to accept.They are not something that we could "touch" and "see", only their influences, but it's not us to judge which are more real. We could only say: it's amazing!