An unstable atomic nucleus can be unstable because of a poor neutron/proton ratio. The weak nuclear force is able to change these ratios by changing one of the quarks inside a proton or a neutron, converting it into another quark of a different type. Beta decay is one example of this type of process, and electron capture is similar in some ways, but performs the opposite transformation. What occurs is that one of the atom's inner shell electrons falls into the nucleus, and is absorbed by a proton there, which turns into a neutron as a result, and emits a neutrino:

p + e- -> n + ν

One of the outer shell electrons will probably fall into the state left by the capture of the inner shell electron, and will cause the emission of an x-ray photon as a result. The x-ray emitted will be characteristic of the newly created element, not the original one, and the process of electron capture can be recognized as a result.

At the quark level, what happens is one of the up quarks inside the proton emits a + boson, and turns into a down quark, turning the whole proton into a neutron. One of the atomic electrons nearby receives this W + boson, turning it into a neutrino. As the down quark is heavier than an up quark, extra energy needs to be present for this type of interaction to occur. In nature, this almost always (but see below) comes from the general instability of an atomic nucleus, so after an electron capture, the configuration is generally more stable so it will be less likely to occur again.

This process is very similar to positron emission, and produces the same result, with a nuclear proton turning into neutron, so the two methods are competitive with each other. Electron capture occurs more often for elements with high atomic number, as the electrons in the inner shells are closer to the nucleus, which promotes their interaction with it. As most of the naturally occuring radionuclides are of high atomic number, this process is generally more common than positron emission.

Electron capture is also what happens in the catastrophic gravitational collapse of a massive star to form a neutron star. When this happens there is sufficient energy due to the gravitational collapse to allow protons in the stellar core to capture electrons, so eventually all of the protons in the stellar core will capture all of the electrons, and a star made completely of neutrons will be created. Electron capture is also important in some kinds of nuclear fusion reactions, such as the proton-proton chain that occurs in stars like the sun.

The main health hazard associated with an element that does electron capture is mainly from the x-rays that are emitted due to the reshuffling of the electron pecking order in the atom. This is a lot less dangerous than gamma rays, but it's still ionizing radiation, and should be treated accordingly.