And, more specifically:
https://en.wikipedia.org/wiki/Elementary_charge#Charges_less...
Basically, quarks seem to have charges that are 1/3 e. However, they can only be stable in groups of three, and those groups must have an integer value. So the only possibilities are -1, 0, and 1.
As to why the above is true, it just seems to be a rule. We don't have any good reasoning for why that rule exists.
charge, baryon number, isospin and strangeness are all related by the Gell-Mann-Nishijima formula[1].
the overarching principle underlying this is that in quantum chromodynamics, the theory of the strong interaction, quarks are representations of an underlying SU(3) gauge group containing color charge (a quantum number) and electric charge quantized as -1/3e and +2/3e. QCD is a gauge theory (like all other theories of nature) and the gauge boson, the gluon, also pops out of demanding the theory be invariant under local SU(3) gauge transformations.
that said, no one has any clue why all of our physical theories are gauge theories :-)
https://en.wikipedia.org/wiki/Gell-Mann%E2%80%93Nishijima_fo...