Neutrons do not have an electric charge because they are composed of quarks with both positive and negative charges that cancel each other out. A neutron is made up of three quarks: two down quarks and one up quark. The down quark has a charge of -1/3 and the up quark has a charge of +2/3 (in units of elementary charge).
When you add up the charges of the quarks in a neutron, the charges cancel each other out:
(-1/3) + (-1/3) + (+2/3) = 0.
Therefore, the net charge of a neutron is zero, making it electrically neutral.
In contrast, protons are also composed of three quarks, but they have different quark compositions. A proton consists of two up quarks and one down quark. The two up quarks have a charge of +2/3 each, and the down quark has a charge of -1/3. When you add up the charges of the quarks in a proton, they combine to give a net charge of +1, which is the elementary charge.
So, while protons have a positive charge and electrons have a negative charge, neutrons are composed of quarks that balance each other's charges, resulting in a neutral overall charge.