Antibodies are proteins that recognize and bind to alien molecules. Because there are an almost infinite variety of possible alien molecules, a correspondingly vast number of different antibody molecules are needed.
The amino acids making up protein molecules can certainly be arranged to give an almost infinite number of different sequences and, therefore, of different shapes. However, this leads to a major genetic problem.
If a separate gene encoded each antibody protein, this would require a gigantic number of genes and a vast amount of DNA. Even if all the DNA in the mammalian genome was coding DNA, it could encode only a few million antibodies, which is far too few.
The answer is that the immune system generates a vast array of different protein sequences from a relatively small number of genes by shuffling gene segments. Instead of storing complete genes for each antibody, the immune system assembles antibody genes from a collection of shorter DNA segments.
Shuffling and joining these partial genes allows the generation of an immense variety of antibodies. This idea is illustrated using three alternative front ends and three rear ends. Combining them in all possible ways gives nine different genes. Suppose that we had 10 different front, middle, and end segments. These could be combined to give 10 × 10 × 10 = 1000 variants. This is closer to what really happens with antibody genes. Note that generating 1000 different proteins in this way would require only 30 segments of coding DNA to be stored on the chromosomes.