This is a question that the very smartest physicists are trying to answer. At the moment we’ve simply drawn up a table of the most basic particles (called the standard model) and from this you can construct all the other particles. But I don’t think that this in any way answers ‘why’ they have those particular masses. The idea that they have at the moment ( I don’t know all the details, just the gist) is that instead of particles everything is a little string of energy. If you had a string in your hand and you were to just hold it still it’d have no energy, but if you wave your hand you can give it a bit of energy. In the same way, big particles are actually energy strings that are waving frantically, and small, light particles would be energy strings that are vibrating more gently.
The trick is, at very small scales you can only give or take away specific packets of energy, never half a packet (think of money – you can never buy something worth 0.5p). So in this way we can have the strings with only one packet of energy, then strings with 2 packets and three packets and so on.
If you look at what size particles these strings actually turn out to give it looks nothing like the standard model (so most people would think the theory is wrong). However, the theory itself is really nice, mathematically speaking, so they thought about it some more and realised that if only we didn’t live in 3 dimensions, but instead more like 11 dimensions then this idea of vibrating strings might actually give us something that looks like the standard model.
So now the big question is where did all the extra dimensions go? They think you might be able to roll dimensions up (imaging taking a big sheet of paper with 2 dimensions and then rolling into a really tight cylinder, it now looks like it only has 1 dimension). But they need to figure out how they might be rolled up (rolling up 11 dimensions to get 3 is more complicated than rolling up 2 to get 1).
So I guess people are trying to answer the question, but it’s defeating some of the worlds best minds.
The Standard Model of particle physics explains some relations between particle masses, and if/when we can find a theory of everything, it will hopefully explain more. However, I would be very surprised if the theory would actually predict the precise masses of all particles. For example, string theory is believed to have a huge set of possible solutions, each one of which predicts different masses. Therefore we would still have to explain why we live in one of those solutions, and not in any other. Perhaps this can be understood by using the anthropic principle because if the masses were different, life might not be possible.