How come neutrons in a nucleus don't decay? I know outside a nucleus, neutrons are unstable and they have half life of about 15 minutes. But when they are together with protons inside the nucleus, they are stable. How does that happen?
I got this from wikipedia:

When bound inside of a nucleus, the instability of a single neutron to beta decay is balanced against the instability that would be acquired by the nucleus as a whole if an additional proton were to participate in repulsive interactions with the other protons that are already present in the nucleus. As such, although free neutrons are unstable, bound neutrons are not necessarily so. The same reasoning explains why protons, which are stable in empty space, may transform into neutrons when bound inside of a nucleus.

But I don't think I get what that really means. What happens inside the nucleus that makes neutrons stable?
Is it the same thing that happens inside a neutron star's core? Because, neutrons seem to be stable in there too.
 A: Spontaneous processes such as neutron decay require that the final state is lower in energy than the initial state. In (stable) nuclei, this is not the case, because the energy you gain from the neutron decay is lower than the energy it costs you to have an additional proton in the core.
For neutron decay in the nuclei to be energetically favorable, the energy gained by the decay must be larger than the energy cost of adding that proton. This generally happens in neutron-rich isotopes:

An example is the $\beta^-$-decay of Cesium:
$$\phantom{Cs}^{137}_{55} \mathrm{Cs} \rightarrow \vphantom{Ba}^{137}_{56}\mathrm{Ba} + e^- + \bar{\nu}_e$$
For a first impression of the energies involved, you can consult the semi-empirical Bethe-Weizsäcker formula which lets you plug in the number of protons and neutrons and tells you the binding energy of the nucleus. By comparing the energies of two nuclei related via the $\beta^-$-decay you can tell whether or not this process should be possible.
A: The Pauli Exclusion Principle states that no two identical fermions (neutrons and protons are fermions - they have half-integer spins and obey Fermi-Dirac statistics) can occupy the same quantum state at the same time. If the neutron were to $\beta$-decay as:
\begin{equation}
n \longrightarrow p + e^- + \bar{\nu_e}
\end{equation}
then this freshly minted proton will try to occupy the quantum state with the lowest possible energy. However, since there are already loads of protons in the nucleus, this 'new' proton can't do that, and so will be forced to occupy a state with higher energy. In order to get to that state, it must absorb some energy. This is why neutrons don't usually $\beta$-decay inside the nucleus. Do remember that $\beta$-decay of neutrons inside the nucleus isn't unheard of - just uncommon.
A: Think dynamically -  I suggest that inside the Nucleus protons and Neutrons are continuously 'flipping' Neutrons decaying into protons and protons absorbing the electron and neutrino to become Neutrons again and so forth. It is this mechanism which gives rise to the binding Force. The Neutron obviously plays a key role in the stability of any heavier then Hydrogen Nucleus.
Exactly how this mechanism works is unclear but perhaps there will exist a net -ve charge due to the brief existence of the electron in the decay/re-absorption process.
This force would be given by Coulomb's Law
$$F \propto \frac{Q_pQ_e}{r^2}$$
where $r$ is of the order of the diameter of a proton resulting in a very strong force
It also avoids introducing "Massive Exchange Particle" that when "Exchanged" create an "attractive" Force
A: Regarding neutrons in neutron stars the answer is a direct extension of the argument use by madR. In a neutron star there are mostly "free" neutrons and the question then is why they don't all beta decay into electrons and protons?
Well, some of them do, but the point is that when the electron/proton (there are equal numbers of each) numbers build up, they become degenerate and the corresponding Fermi-energies increase. At some threshold number density, their Fermi energies will exceed the maximum energy of the particles that can be produced by beta-decaying neutrons. At that point beta decay pretty much stops and an equilibrium is set up between beta decay and inverse beta decay such that the Fermi energies of the species are related by
$$E_{F,n} = E_{F,p} + E_{f,e} $$
A: You asked HOW it is that the bonded neutron is stable, but the free neutron is not: 'What happens inside the nucleus that makes neutrons stable?'
This is an ontological question and these are the hardest to answer. The best answer you can get in terms of conventional physics is differences in binding energy, as Lagerbaer explained. The Table of Nuclides gives empirical evidence THAT binding energy is strongly associated with nuclide stability (but interestingly is not perfectly so). However, that still does not answer the HOW & WHY questions. WHY do those energy differences exist?
If you have a curious mind, you will find other explanations of this effect, but these are less orthodox. Our own explanation is here and is given in terms of a hidden-variable solution
http://vixra.org/abs/1111.0023
An extract from the ABSTRACT reads:
Findings - The stability of the neutron inside the nucleus is found to arise from the formation of a complementary bound state with the proton. The neutron is an intermediary between the protons, as the discrete forces of the protons are otherwise incompatible. This bond also gives a full complement of discrete forces to the neutron, hence its stability within the nucleus. The instability of the free neutron arises because its own discrete field structures are incomplete. Consequently, it is vulnerable to external perturbation.
The paper goes on to explain how this is proposed to operate, in terms of ordered structural interactions between nucleons (nuclear polymer). We would emphasize that this explanation is unorthodox. Nonetheless it does have a broader usefulness since the same mechanics are able to explain the related and even more difficult problem of why any one nuclide (not just the neutron on its own) is stable/unstable/non-existent for the range Hydrogen to Neon (at least) http://dx.doi.org/10.5539/apr.v5n6p145
So the deeper question is why the free neutron (n) is unstable, why 1H1 is stable, but 1H2 is unstable (but has a longer life than n), and 1H3 is wildly unstable? We think we can explain all that, and all the others all the way to at least Neon. This region of the table of nuclides is otherwise notoriously difficult to explain.
So maybe that explanation for the stability/instability of the neutron is not so crazy after all. 
A: Neutrons exchange charge inside a proton. When outside the confines of a nucleus it continues to try to reach a state of neutrality. Such a state stops charge interaction, complete neutrality can not be achieved, so it breaks apart to again reach an active state of charge flow.  I would suggest looking at Yukawa's concepts of pions.  
A: 
But when they are together with protons inside the nucleus, they are stable.

You don't know that neutrons are stable inside the nucleus. It's an assumption.
When they are apart from the nucleus, they separate into pieces which go their own way. The effect can be measured. Observe the pieces.
If a neutron separates into pieces which don't leave the nucleus, there's no reason to think it's still a neutron. It could be, for example, a collection of quarks that scatter throughout the nucleus.
There is some data about what happens inside atomic nuclei, particularly data about what comes out of them when they are bombarded with high-energy particles. The limited data CAN be interpreted in terms of protons and neutrons that maintain individual identities. There's no particular reason to believe that as more data becomes available, this hypothesis will look like the best one.
