In keeping with the concept that people of earlier ages were not stupid, it was long understood that most reproduction produced offspring that somehow were a combination of the traits of the parents. If you bred individuals with some common trait together, you increased the chance that such a trait would be prominent in the offspring, but it didn't always work that way. You could make plant cuttings and pretty much get a duplicate plant, traitwise, but pollination produced the same sort of mixtures that animal reproduction gave. How did it work? Were there hidden rules that could be discovered and applied to make results more predictable?
Gregor Mendel was fascinated with science and Nature, but in order to continue his education beyond a certain point, he had to enter a monastery in what was then Austria (now Brno of the Czech Republic). In a classic example of using the materials at hand, Mendel took advantage of the monastery's production of peas: for years he bred peas in special separate plots, focusing on a few one-or-the-other features (such as Tall / Short, or Wrinkly Pea / Smooth Pea) that he could isolate in a "pure" form. After hundreds of tests, with new plots of hybrid plants and plots of hybrid-hybrid crosses, Mendel developed the first basic rules of what would come to be called genetics.
Mendel decided that traits were determined by some sort of internal codes which he called genes. For any particular trait, there might be code variations that changed the nature, like leaf color, or degree of the trait, such as one variation in the Height gene for Tall and one for Short. These variations he called alleles, which he determined to be carried in each individual in pairs (although there may be way more than two allele variations in a population, each individual just carries two), of which only one is passed on to offspring from each parent. For each trait that is determined by a single gene (many traits are produced from multiple genes working together), an individual's particular version of that trait is a product of their two alleles. Mendel thought that every single allele pair was sorted separately for reproduction, which turned out later to not be true, but many of them do sort separately.
As a side effect of Mendel's choice of pea traits, he also discovered a genetic feature called dominance, where the presence of a dominant allele can completely hide the presence of a recessive allele. This either-or condition was necessary to his working out genetic rules, but it has since been found (and he probably realized) that many traits don't follow such an extreme pattern. Many allele effects are not that strong or weak, but rather blend to produce the trait. (In human eye color, very dark alleles can be dominant over very light alleles - brown can dominate blue - but middle-strength alleles blend, such as when green and light brown produce hazel). It also turns out that many traits, in fact most traits, are a product of at least two genes working together, two alleles per gene; these multiple-gene traits do follow rules based upon Mendel's discoveries, but the complex mixing of many alleles makes predictions of offspring traits a matter of probabilities. With all that we know of genetics, breeding racehorses is still a matter of mating parents with desired traits and hoping everything mixes properly in the offspring, which is what breeders were doing before Mendel was born.
Mendel wrote and published several papers on his discoveries, but no one in the scientific community seemed to notice. When he died, as far as he knew his research and findings would make no difference to the world. However, in the very early 1900's, three scientists investigating the same sorts of processes discovered Mendel's papers, and his rules became the foundation of a basic building block of biology today.
We know quite a bit more about genes today. The researchers who followed up on Mendel's work through the 20th century discovered some additional details:
Groups of genes are linked together. It turns out that our cells do not carry thousands of separate codes floating about; genes are bound together along the lengths of chromosomes. This is called linkage: for example, genes that are found on sex chromosomes exhibit sex linkage (not because they have anything to do
particularly with sex, but because they are on "sex-determining" chromosomes). One feature of any species is its characteristic chromosome number, usually an even number in sexually-reproducing species because of the pairs (humans have a chromosome number of 46, 23 pairs). There are advantages and disadvantages to both low and high chromosome numbers: with low numbers, the distribution of copies that must happen whenever new cells are made is easier - there are fewer chromosomes and chromosome copies to control; but with higher numbers, the sorting of various allele combinations goes up, increasing potential variability in offspring, which increases evolutionary flexibility. The numbers among species vary widely, including some protists and plants with amazingly high numbers.
One weakness of Darwin's original theory of evolution is that it could not explain where "new" (really, old but dramatically changed) features came from - natural variations couldnt really explain how snake venom evolved from saliva, for instance. But many years later, mutations were discovered: spontaneous changes in genetic material, producing new alleles that usually have no altering effect on the coded trait, or a bad effect if an effect exists, but occasionally might produce a useful change. And a particular type of mutation, called genetic redundancy (which is actually one of two types of genetic redundancy), could duplicate genes, allowing the mutational change of an existing trait (say, snake saliva to venom through changes of the "extra" saliva gene) while preserving the original action (not losing the original saliva). This might also explain why more "advanced" organisms seemed to have more genes than more "primitive" ones.
Later, it was discovered what exactly a gene is: a stretch of the molecule DNA that contains a sequence that can be used to produce particular proteins. Cells then use those proteins to create the "traits" that Mendel connected to genes. His Height gene, for instance, codes for a type of plant growth hormone. Alleles produce proteins that have molecular differences, sometimes slight, sometimes major, often changing how things work, and how the trait looks.
Since Mendel, it has been discovered that in some circumstances having two different alleles can be better than a pair of either variant, a condition called hybrid vigor. This often is the reason that human genetic diseases have spread through a population. For example, the gene for the oxygen carrier hemoglobin has a allele that makes a nonround version of the protein; if you get a pair of these alleles, it gives you sickle-cell anemia, a dangerous disease that impairs circulation. In areas where malaria, a disease caused by a blood parasite, is common, people carrying one regular hemoglobin allele and one sickle-cell allele have more resistance to malaria than those with two regular alleles, giving them an advantage that passes sickle-cell alleles to their offspring. Other genetic diseases may have similar effects: cystic fibrosis alleles might make single-carriers resistant to diarrhetic diseases (which kill huge numbers across the world), Tay-Sachs seems to produce a tuberculosis resistance, and schizophrenia (which is a multiple-gene trait and harder to sort out) may in some combinations increase creativity and the willingness to take risks.