As it is more massive than a proton, an isolated neutron is unstable, having a half life of about 15 minutes and decaying according to $$ n\to p+e^-. $$$$ n\to p+e^-+\bar{\nu_e}. $$ Neutrons bound to a nucleus have effectively lower mass because of the nuclear binding energy, but too many of them can cause the nucleus with one neutron replaced by a proton to have a lower mass than the original, and so the beta decay occurs.