The strong nuclear force is carried by particles called gluons. Gluons are exchanged between protons and neutrons, and they hold them together by creating a force field between them. The stronger the force field, the stronger the binding between the protons and neutrons.
The strong nuclear force is only strong enough to hold protons and neutrons together if there are enough of them in the nucleus. If there are too few protons and neutrons, the electrostatic force will overcome the strong nuclear force and the nucleus will break apart. This is why only certain combinations of protons and neutrons can form stable nuclei.