Seed-saving - the basics
Why save seeds?
If you cultivate your garden year after year, it makes sense to maintain the complete cycle of plant production in order to keep better control of what you're growing, to reliably grow varieties that you like and which suit your micro-climate, and without being so continually dependent on outside sources.
After a few years (generations of plants) a particular species/variety will often become a little better adapted to the specific area where it's grown, so you may get even better results!
Commercially-produced varieties may be bred more for looks, durability (transport-ability), and for cropping all at once; traditionally developed "heirloom" varieties are often better for the small grower as they may crop more continuously, as well as being often more tasty, even if they don't store very well after picking.
Many heirloom varieties have already been lost, but maintaining a greater diversity of varieties is good for the species as a whole.
Seeds from seed companies are often F1 hybrids (or "filial 1", i.e. 1st generation offspring) from a deliberate cross-breeding of different varieties, and you cannot usefully save seeds from them, so you have to keep buying seeds year after year. Not all bought seeds are like this, but read the label - if it's an F1 hybrid it has to say so. F1 hybrids are like the first stage of trying to produce a new variety and can have desirable characteristics; they might produce fruit early or be resistant to some diseases, and they can show "hybrid vigour" (or "heterosis") which means they are stronger and more productive than their parent varieties, if only for that one generation.
Hybrid varieties can be useful, but most commercially-sold F1 hybrids are either sterile (they produce no seeds or non-viable seeds) or their seeds don’t breed true; their descendants are unpredictable and often not nearly as good as the parent. Seed companies are happy that their F1 plant refinements don't persist to the second (F2) generation of plants and therefore can’t be "stolen", they may even go to some lengths to engineer the genetics of their product to make sure it cannot produce useful seeds. So instead of breeding a new, better and self-perpetuating variety, F1 hybrids, as currently produced, lock us into dependence on the seed company! For us, it is better to produce and maintain true-breeding varieties, and to maintain the excellent but not-so-commercially-viable heirloom varieties.
Having said all that, many seeds you can easily buy in the shops are good, true-breeding varieties. It will always say on the packet, one way or another. The term "open pollinated" is sometimes used for seeds that will breed true - it means they were from plants pollinated by natural means, not from a laboratory-controlled artificial hybrid.
Plant propagation:
We sometimes propagate plants artificially by root-division, cuttings, etc, and some plants also propagate themselves from root suckers, rhizomes or layering (sprouting roots from an "elbow"), and even some apparently natural wild species sometimes tend to do this in preference to making seeds. However, these methods, even if available, only produce a "clone" of the parent, whose genetic make-up is identical or very nearly identical to the (single) parent.
Seeds are part of the process of sexual reproduction in plants, which, as in animals, produces individuals with genetically-carried characteristics from both parents; each parent provides a half-set of chromosomes/genes, so the production of viable seeds can mix up the gene pool much more readily, and tends therefore to evolve the species (increasing resistance to disease or environmental changes) more adeptly and effectively. (Note: some species have evolved - and others have been created - which have more than two "half-sets" of chromosomes; plant genetics is complicated and this text is only a very simple introduction!)
A "viable" seed (one which can germinate and grow when planted) is like a fertilised egg, for example; there has to be a contribution (pollen) from a male part of a flower into the female part of a flower which will then go on to set seed somehow. It may produce a fruit of some sort, or some other kind of seed container or pod. The fruits themselves have often evolved to help the new seeds on their way somehow; for example by attracting birds which might then carry the seeds further away.
Like animals, plants generally only breed successfully with others of the same species. It's true that a horse and a donkey can make a mule, but although mules combine useful qualities of both parents, they can't produce similar offspring.
What is a species?
In origin, the word "species" refers to things that all look the same ("spec..." from Latin as in "spectator" etc.) - but humans now breed many different-looking cultivated varieties (cultivars) of the same species - e.g. nice orange carrots are cultivars of, and the same species as, the thin white wild carrot. The basic idea of a biological species as defined by taxonomists (who classify and name the different types of plants and animals), is that individuals of the same species can successfully breed together, to make fertile offspring which can continue to perpetuate the species.
Names of plant, or animal, species are always given as a "binomial" (two-part) name, e.g. Brassica oleracea or Cucurbita maxima. The first part (which should be capitalised) is the "genus" - a technical term, not quite as broad as "family" but basically a similar idea - and the second part names a unique species within that genus. Carolus ("Carl") Linnaeus (1707–1778) introduced the binomial naming system, as a simplification of the very descriptive but extremely long-winded naming system then in use. (The plural of "genus" is "genera" or sometimes now, in English, "genuses".)
We sometimes also (although it's often a bit arbitrary and sometimes subject to disagreement) have "sub-species", where a species has naturally divided into groups that tend not to mix (perhaps because of geographical separation) and so have developed their own separate characteristics, but without evolving so much as to become a separate new species. E.g. "Chinese cabbage" (pak choi etc.) is often considered a subspecies of the turnip/field-mustard species: Brassica rapa subsp. chinensis. Different subspecies are usually still sexually compatible though, and will cross with other subspecies of the same species.
We also have many artificial "cultivars" (i.e. "cultivated varieties") of some species or sub-species, like different kinds of cabbage or pumpkin etc. (Equivalent to "breeds" in the case of animals, like dogs, cattle etc.) These cultivated varieties are usually what we are trying to maintain through carefully producing and saving seeds.
Note: taxonomists do sometimes change their minds, in the light of new discoveries, and occasionally plants do get reclassified by later generations of taxonomists! Also, cross-fertilisation can very occasionally happen between certain different but closely-related species, as they are currently defined - for example, it appears that Capsicum baccatum chillies may cross-fertilise with C. annuum (the more usual species of peppers). On the whole though, especially for commonly-grown plants, their various seed-making quirks are quite well-studied.
How are seeds made?
The sexual parts of plants (pistils and stamens) are contained in the flowers. Flowers of some species contain both male and female parts (these are called "perfect" or "monoclinous" flowers), and sometimes these can self-pollinate, needing no other flower. In other species, each flower only has either female or male parts but not both ("imperfect"/"diclinous" flowers), and to make a fruit, a female flower has to be "cross-pollinated" from a male flower. Thirdly, some species produce plants with only one sex of flower on any single plant, so you have separate female and male plants.
This transfer of pollen is usually performed by insects such as bees, although many plants instead are adapted to be wind-pollinated - many grasses (grains) are like this, producing lots of fine pollen carried on the breeze, causing hay-fever! "Cross-pollination" really just means this natural pollination, by wind or insects, from a male flower to a female flower of the same variety, but can also refer to the (usually unwanted) pollination from a male of a different variety to the mother plant, which will produce seeds that are a cross of two varieties. (Be aware that e.g. some gardening websites carelessly use the term "cross-pollination" always to imply this unwanted crossing of different varieties.)
Also, many species - sometimes whole families of plant types - are cleverly "self-incompatible" which means that although they may have both sexes of flower on one plant, nevertheless a female flower won't actually make fruit/seed, or not successfully, unless it's pollinated from a male flower from a different plant (and not an exact genetic clone either!). This is "outcrossing" or "out-breeding" - which increases genetic diversity and thus can make the species more resilient to disease etc. - and is enforced by the genetic mechanisms within the plant itself. Plants have evolved several distinct and quite complicated ways to accomplish this, many details of which are still not fully understood by science. Very many species from the genera Brassicaceae (cabbages and turnips etc.), Asteraceae (sunflowers, lettuce, etc.) and Poaceae (grasses, i.e. grains etc.), as well as many others, are self-incompatible. Thus, in order to get good seeds, it's necessary to grow, say, at least half-a-dozen cabbage-type plants of the same variety, so that the female flowers can be sure of finding enough genetic diversity in the pollen they are given, in order properly to set seed. (If maintaining a variety over some generations, it's best to have even more plants.)
Plants with self-pollinating flowers, on the other hand, like tomatoes, chillies or aubergines, don't need pollinating insects; pollen just falls from a stamen onto the receptive part of the pistil, and only a single flower is needed to produce a fruit with viable seeds.
If you do save seeds which are the result of crossing different varieties, you may notice their hybrid vigour when they first start. This looks great, but could be a warning sign! If the seeds are all from one fruit, then the new plants will all look similar, but because they are hybrids then their offspring may vary a lot, showing random signs of their various grand-parent plants. Still, if you select the best (or select for the traits you want) and carry on for a few years then you'll be a plant-breeder!
Breeding true-to-type:
Many plant species have been associated with humans for a long time, and have become domesticated into particularly useful or pleasing cultivated varieties. E.g., within the "Brassica" genus: broccoli, Brussels sprouts, savoy cabbage, cauliflower, fractal "romanesco" green cauliflower, purple sprouting broccoli, collards, curly kale, tree kale, red, white or green salad cabbages, and variegated ornamental cabbages, are all the same species! (B. oleracea). They will interbreed if they can (if they're in flower at the same time and sufficiently close together that a pollinating insect can go from one straight to the other). Or e.g. most of the great range of types of "squash" (from pumpkins to courgettes, butternuts, marrows etc.) are of just three different species (although there are a couple of other, less common, species too) - varieties of the same species of squash can interbreed, but different species won't, so check which species you're growing!
Some species are much less promiscuous than others; for example the flowers on pea plants, and on most (standard-sized and smaller) tomatoes, never even open fully to the outside, so insects simply cannot get in to cross-pollinate from a different variety! (I suppose this doesn't do much for their genetic diversity, though.)
Beef tomatoes may have their flowers open, so although they do self-pollinate they can also get crossed from another beef tomato variety in the same garden. The same is true for aubergines and for peppers, so e.g. if you grow more than one type of chilli or sweet pepper you will need to isolate a budding flower from cross-pollination in order to produce true seeds. This is only necessary for the fruits you're keeping for seed; for the ones that you eat it doesn't matter what pollinated them!
Some varieties we grow may cross with wild plants, e.g. a nice orange carrot can be pollinated from the (commonly found around here) wild carrot (aka Queen Anne's Lace) from which it is derived; this won't visibly affect that carrot itself, but its seeds will produce surprises in your next generation of carrots. The wild carrot is the same species (Daucus carota) as its much larger-rooted and tender cultivars; you can still eat them - the wild carrot was eaten by the Romans and many other peoples - the roots are whitish in colour and quite sweet but much thinner and tougher than the cultivated varieties of carrot.
Ways to prevent unwanted cross-pollination:
If we want to grow more than one variety of a species, then in order to get true-bred seeds we need to ensure that the fruits we keep for seed were only pollinated by the same variety. For a chilli, or an aubergine, for example, this is quite easy; it is self-pollinating, and so we just need to prevent it from being pollinated by anything else! We can do this with lightweight netting, fine enough to keep insects out, either over the whole plant using an "isolation cage", or around just one flower using a little net bag with a string to hold it closed around the stem bearing the flower. Using fine netting (not, e.g. a plastic bag!) means that the plant can still breathe, and will not overheat in the sun. Once some fruit is set, we know that it will contain true-to-type seeds, so we can mark those particular fruits to be saved for seeds, and remove the netting.
For plants with flowers that don't self-pollinate, a little more thought is needed. The simplest way, if you have the space, is to have the different varieties you want to grow a good distance from each other. That way, pollinating insects are likely to go somewhere else first, and not directly from the one variety to the other, so the chance of unwanted cross-pollination is small. You can also have some barrier, like some other flowering plant, in between the two varieties, so that insects will tend to visit these on their way, and the unwanted pollen will be cleaned off.
You can also grow your plants of one variety in a block all together, and only use plants from the middle as seed-givers. That way the bees etc. will be likely to have cleaned off any other pollen on the outer plants of the block, before they get to the middle plants, again reducing the chance of unwanted cross-pollination.
As an alternative to this general approach of keeping the different varieties in different places, physically isolated or distant from each other, you may instead be able to arrange that your different varieties are in flower, or allowed to flower, at different times, and thus cannot cross-pollinate each other. So for example, you might be able to grow an early and a late variety of green beans in the same season, one after the other. Or, if you are in the garden frequently enough, you may be able to remove the flowers of all but one variety of a species, before they open. Then when your chosen variety has set some seeds/fruit, which you know must be true-bred, you can let the flowers bloom on the other variety instead.
Finally, for some species, we can sidestep natural means altogether, and do the pollinating ourselves! Squash/courgette flowers can be bagged or taped closed when they first appear, and pollinated by hand. So long as you are able to spot the flowers - one of each sex - before they properly open, then you can hand-pollinate, and be sure of getting at least that one fruit with true-bred seeds. You need to stop the male flower opening too, before you use its pollen, to ensure that a passing bee doesn't bring any unwanted pollen into the male flower from elsewhere and leave it there, where it might get mixed up with the pollen you actually want to use. Tape the female flower closed again after the act, so that no other pollen gets in.
So, with enough forethought and effort, it's possible to prevent unwanted cross-pollination in most varieties most of the time. Alternatively, you can simply get around the problem by taking care to grow no more than one variety of any species at a time, and still grow a wide range of different vegetables!
Other considerations:
Generally seeds should be allowed to ripen completely on the plant, before collecting them. The best way then to preserve them depends on the species. Tomato seeds for example have a natural gel around them, which actually inhibits the germination of the seed while it's still in the fruit; to save the seeds this needs to be washed, or preferably fermented, away - see the info sheet on tomatoes. Beans and peas, when they have dried completely hard, should be put in a freezer to kill any weevil eggs that are inside them already (the weevils lay their eggs inside the flower!) For more detailed information, you could look at the guide "How to take seeds from various different species" from the information sheets on the seeed.es website.
With some species, saving seeds from a plant means that we can't eat it, e.g. a leek can either be eaten or allowed to flower and set seed. Nevertheless, try to save seeds from some of your best plants!
To allow seeds to mature and ripen naturally before harvesting them, the plants may need to stay in the ground longer, so you may need a little more space in your garden!
Some people, if they're growing a lot of food for example, find it easier, for some crops, to allocate a different part of the garden for seed production, separate from crop/food production, so that e.g. the crop plants can be cleared when they've finished cropping, while the seed plants can stay in their patch a little longer, as necessary.
Once a plant has started to go to seed, or "bolted", it often becomes less good to eat (it may get harder/woody or bitter) or stops producing more fruits. Sometimes we will keep picking and eating until near the end of the season, and then let some plants go to seed. A change in the weather, or in the watering regime, can trigger some plants to go to seed.
Good luck :)