Free protons are stable particles, meaning they do not decay over time. This stability is due to the conservation of certain fundamental properties, such as electric charge and baryon number. The proton is the lightest baryon, and it is the only baryon with a positive charge. It is the lightest particle that can carry an electric charge, and there is no lighter particle to which it can decay while conserving electric charge.
On the other hand, free neutrons are unstable particles and undergo a process called beta decay. A neutron consists of two down quarks and one up quark, while a proton consists of two up quarks and one down quark. In beta decay, a neutron can transform into a proton, an electron, and an electron antineutrino. One of the down quarks in the neutron changes into an up quark, emitting a W- boson. The W- boson then decays into an electron and an electron antineutrino.
The reason why free neutrons undergo beta decay while free protons do not is related to the difference in energy between the two particles. The mass of a neutron is slightly greater than the mass of a proton. The energy difference between a neutron and a proton is made up by the energy released in the beta decay process, allowing the decay to occur.
In atomic nuclei, where neutrons and protons are bound together, the stability of a nucleus depends on the overall balance between the strong nuclear force that binds the nucleons (protons and neutrons) and the repulsive electromagnetic force between the positively charged protons. Stable nuclei typically have a roughly equal number of protons and neutrons, as this configuration minimizes the electrostatic repulsion while maximizing the strong nuclear force.