Nitrogen fixation is the transformation of inorganic, molecular nitrogen into ammonia, which is then incorporated into organic molecules. The presence of nitrogen in a usable form is perhaps the major rate limiting factor in the growth of plants, at least as far as substances are concerned (heat and light are also obvious factors). This is somewhat ironic: molecular nitrogen makes up over seventy percent of the atmosphere, and yet is unusable, while carbon dioxide, which makes up about 3 parts in 10,000, is easily converted by plans into usable carbon via photosynthesis.
The reason atmospheric nitrogen is unable for easy use is because it consists of two nitrogen atoms that share three covalent bonds with each other. Sharing these three bonds means that they are very close together, and thus need much energy to be broken apart. (As a side note, carbon molecules with triple bonds, such as acetylene, are highly reactive and burn with great energy. The difference lies in some formulations of quantum physics and electron orbitals that are out of the scope of this writeup.)
And yet living things need nitrogen, and lots of it, primarily to form amino acids and therefore proteins. So there are a number of ways that this happens. First, lightning splits some atmospheric nitrogen into atomic nitrogen, some of which quickly combines with atmospheric oxygen (either molecular or atomic), and then falls to the ground. Incoming cosmic rays also lead to the same reaction, and although this might currently be inconsequential, it may have been a much more important source of fixed nitrogen early in the earth's history.
Much fixed nitrogen is also made industrially, using a reaction that is, to use a technical chemical term, hardcore. To turn reluctant atmospheric nitrogen into usable nitrogen, molecular nitrogen and molecular hydrogen are mixed together at several hundred atmospheres and several hundred degrees Celsius, with a metallic catalyst. This process is very important, and provides the world with fertilizer that probably keeps it from starving. But as could be believed, it is also not something that can be done without a lot of energy and technology.
So far, we have looked at fixing nitrogen with lightning, cosmic rays and intense technology. All of these things are fairly intense, difficult processes, and would not be able to fix enough nitrogen to keep a biosphere running by themselves. Especially considering that there was a biosphere for a long time before there was industrial nitrogen fixing. The majority of nitrogen fixing is done by very small bacteria, most of which live in the root nodules of a small number of plants, mostly of the legume family. The bacteria do this using a special group of proteins, that manage to separate enough electrons out, and then pass them on to another protein, which has a co-factor utilizing iron, sulfur and a single molybdenum atom. The cofactor holds the molecular nitrogen in place, and then bombards the metal atoms with so much electrons that they are able to pull the molecular nitrogen apart. The full description of what happens is more complicated, of course. The reaction takes so much energy, and produces so many toxic products, that it would probably be lethal inside of the cells of a higher plant, but the bacteria are able to produce the nitrogen without too many ill effects.
What is most incredible to me is the fact that small bacteria, using nothing but an organic protein with some iron and a molybdenum atom, are able to do something that otherwise requires the immense energy of lightning flashes or heavy industrial processes. It also says something about the mutual elegance and inelegance of life on earth. While almost all of the earth's plants are busy breaking apart and using the vanishingly tiny amount of carbon dioxide in the atmosphere, the just as vital task of breaking the gigantic amount of atmospheric nitrogen is left to a small amount of bacteria living inside of the roots of several plants. And the bacteria does that through a Rube Goldberg protein that utilizes a complicated core of metal atoms. "Molybdenum" may not be high on most people's list of necessities for life, and yet it is. (Almost) every nitrogen atom in your body was once next to a molybdenum atom inside a bacteria inside a pea plant). There is much better technical explanations for the process of nitrogen fixation, but I hope this writeup has given some feeling for the complication and oddity of the matter.