In a neutron star there are mostly "free" neutrons and the question then is why don't they all beta-decay into electrons and protons?
Well, some of them do, but the point is that when the electron (or proton, there are equal numbers of each) numbers build up then they become degenerate (meaning no more than two electrons [spin-up and spin-down] can occupy the same momentum/energy state and all energy states are filled up to a "Fermi energy" that increases with electron density) and their Fermi-energies increase. At some threshold number density, the electron Fermi energy will exceed the maximum energy of the electron that can be produced by beta-decaying neutrons. At that point beta decay pretty much stops because there are no available states that can be filled by the decay electron and an equilibrium is set up between occasional beta decays and inverse beta decays such that the Fermi energies of the species are related by
$$ E_{F,n} = E_{F,p} + E_{f,e}$$
It isn't the case that this is just an equilibrium condition where half the neutrons in a neutron star will decay in 10 mins but be replaced by inverse beta decay at the same rate. The beta decay and inverse beta decay reactions are heavily suppressed (at least when the neutron to proton ratio is >8) because it is not possible (in degenerate gases) to simultaneously conserve both energy and momentum in these reactions once the equilibrium state has been achieved, and so other processes involving bystander particles (modified URCA process, MURCA) have to be invoked, which are much less efficient (see What allows the modified Urca process to work at lower density than direct Urca in neutron star cooling?).
A quick calculation is highly illuminating. If the MURCA process operates, this generates a neutrino luminosity of about $10^{33}$ W in a typical neutron star at interior temperatures of $\sim 10^9$K (Friman & Maxwell 1979). Each neutrino/anti-neutrino has an energy $\sim kT$ and there are $\simeq 10^{57}$ neutrons in a neutron star. For each beta decay of a neutron in the MURCA process, a neutrino and an anti-neutrino are produced; hence the lifetime of a typical neutron is $\sim 3\times 10^{10}$ seconds (or $\sim 1000$ years). If the URCA process were possible and neutrons decayed on a 10 minute timescale, then the cooling timescale of a neutron star would be seconds, since each neutron in a degenerate gas has $\ll kT$ of thermal energy.