In biology, immunity is the balanced state of multicellular organisms having adequate biological defenses to fight infection, disease, or other unwanted biological invasion, while having adequate tolerance to avoid allergy, and autoimmune diseases.
Innate and adaptive
Immunity is the capability of multicellular organisms to resist harmful microorganisms from entering it. Immunity involves both specific and nonspecific components. The nonspecific components act as barriers or eliminators of a wide range of pathogens irrespective of their antigenic make-up. Other components of the immune system adapt themselves to each new disease encountered and are able to generate pathogen-specific immunity.
An immune system may contain innate and adaptive components. The innate system in mammalians for example is composed of primitive bone marrow cells that are programmed to recognise foreign substances and react. The adaptive system is composed of more advanced lymphatic cells that are programmed to recognise self substances and don't react. The reaction to foreign substances is etymologically described as inflammation, meaning to set on fire. The non-reaction to self substances is described as immunity, meaning to exempt or as immunotolerance. These two components of the immune system create a dynamic biological environment where "health" can be seen as a physical state where the self is immunologically spared, and what is foreign is inflammatorily and immunologically eliminated. "Disease" can arise when what is foreign cannot be eliminated or what is self is not spared.
Innate immunity, also called native immunity, exists by virtue of an organisms constitution, that is its genetic make-up, without an external stimulation or a previous infection. It is divided into two types: (a) Non-Specific innate immunity, a degree of resistance to all infections in general. (b) Specific innate immunity, a resistance to a particular kind of microorganism only. As a result, some races, specific individuals or breeds in agriculture do not suffer from certain infectious diseases.
Adaptive immunity can be sub-divided depending on how the immunity was introduced in 'naturally acquired'through chance contact with a disease causing agent, whereas 'artificially acquired immunity' develops through deliberate actions such as vaccination. Both naturally and artificially acquired immunity can be further subdivided depending on whether the host built up immunity itself by antigen as 'active immunity' and lasts long-term, sometimes lifelong. 'Passive immunity' is acquired through transfer (injection or infusion) of antibodies or activated T-cells from an immune host; it is short lived—usually lasting only a few months. The diagram below summarizes these divisions of immunity.
Adaptive immunity can also be divided by the type of immune mediators involved; humoral immunity is the aspect of immunity that is mediated by secreted antibodies, whereas cell mediated immunity involves T-lymphocytes alone. Humoral immunity is called active when the organism generates its own antibodies, and passive when antibodies are transferred between individuals or species. Similarly, cell mediated immunity is active when the organisms’ own T-cells are stimulated, and passive when T cells come from another organism.
History of theories
The concept of immunity has intrigued mankind for thousands of years. The prehistoric view of disease was that it was caused by supernatural forces, and that illness was a form of theurgic punishment for "bad deeds" or "evil thoughts" visited upon the soul by the gods or by one's enemies.  Between the time of Hippocrates and the 19th century, when the foundations of the scientific methods were laid, diseases were attributed to an alteration or imbalance in one of the four humors (blood, phlegm, yellow bile or black bile). Also popular during this time before learning that communicable diseases came from germs/microbes was the miasma theory, which held that diseases such as cholera or the Black Plague were caused by a miasma, a noxious form of "bad air".  If someone were exposed to the miasma in a swamp, in evening air, or breathing air in a sickroom or hospital ward, they could get a disease.
The modern word "immunity" derives from the Latin immunis, meaning exemption from military service, tax payments or other public services.  The first written descriptions of the concept of immunity may have been made by the Athenian Thucydides who, in 430 BC, described that when the plague hit Athens: "the sick and the dying were tended by the pitying care of those who had recovered, because they knew the course of the disease and were themselves free from apprehensions. For no one was ever attacked a second time, or not with a fatal result".  The term "immunes", is also found in the epic poem " Pharsalia " written around 60 B.C. by the poet Marcus Annaeus Lucanus to describe a North African tribe's resistance to snake venom.
The first clinical description of immunity which arose from a specific disease causing organism is probably Kitab fi al-jadari wa-al-hasbah ('A Treatise on Smallpox and Measles', translated 1848  ) written by the Islamic physician Al-Razi in the 9th century. In the treatise, Al Razi describes the clinical presentation of smallpox and measles and goes on to indicate that exposure to these specific agents confers lasting immunity (although he does not use this term). The first scientist who developed full theory of immunity was after he revealed phagocytosis in 1882. With Louis Pasteur's germ theory of disease, the fledgling science of immunology began to explain how bacteria caused disease, and how, following infection, the human body gained the ability to resist further infections. 
The birth of active immunotherapy may have begun with Mithridates VI of Pontus. To induce active immunity for snake venom, he recommended using a method similar to modern toxoid serum therapy, by drinking the blood of animals which fed on venomous snakes. According to Jean de Maleissye, Mithridates assumed that animals feeding on venomous snakes acquired some detoxifying property in their bodies, and their blood must contain attenuated or transformed components of the snake venom. The action of those components might be strengthening the body to resist against the venom instead of exerting toxic effect. Mithridates reasoned that, by drinking the blood of these animals, he could acquire the similar resistance to the snake venom as the animals feeding on the snakes. Similarly, he sought to harden himself against poison, and took daily sub-lethal doses to build tolerance. Mithridates is also said to have fashioned a 'universal antidote' to protect him from all earthly poisons. For nearly 2000 years, poisons were thought to be the proximate cause of disease, and a complicated mixture of ingredients, called Mithridate, was used to cure poisoning during the Renaissance. An updated version of this cure, Theriacum Andromachi, was used well into the 19th century.  In 1888 Emile Roux and Alexandre Yersin isolated diphtheria toxin, and following the 1890 discovery by Behring and Kitasato of antitoxin based immunity to diphtheria and tetanus, the antitoxin became the first major success of modern therapeutic Immunology.
In Europe, the induction of active immunity emerged in an attempt to contain smallpox. Immunization, however, had existed in various forms for at least a thousand years.  The earliest use of immunization is unknown, however, around 1000 A.D. the Chinese began practicing a form of immunization by drying and inhaling powders derived from the crusts of smallpox lesions.  Around the fifteenth century in India, the Ottoman Empire, and east Africa, the practice of inoculation (poking the skin with powdered material derived from smallpox crusts) became quite common.  This practice was first introduced into the west in 1721 by Lady Mary Wortley Montagu.  In 1798, Edward Jenner introduced the far safer method of deliberate infection with cowpox virus, ( smallpox vaccine), which caused a mild infection that also induced immunity to smallpox. By 1800 the procedure was referred to as vaccination. To avoid confusion, smallpox inoculation was increasingly referred to as variolation, and it became common practice to use this term without regard for chronology. The success and general acceptance of Jenner's procedure would later drive the general nature of vaccination developed by Pasteur and others towards the end of the 19th century. In 1891, Pasteur widened the definition of vaccine in honour of Jenner and it then became essential to qualify the term, by referring to polio vaccine, measles vaccine etc.
Passive immunity is the transfer of active immunity, in the form of readymade antibodies, from one individual to another. Passive immunity can occur naturally, when maternal antibodies are transferred to the foetus through the placenta, and can also be induced artificially, when high levels of human (or horse) antibodies specific for a pathogen or toxin are transferred to non- immune individuals. Passive immunization is used when there is a high risk of infection and insufficient time for the body to develop its own immune response, or to reduce the symptoms of ongoing or immunosuppressive diseases.  Passive immunity provides immediate protection, but the body does not develop memory, therefore the patient is at risk of being infected by the same pathogen later. 
Maternal passive immunity is a type of naturally acquired passive immunity, and refers to antibody -mediated immunity conveyed to a fetus by its mother during pregnancy. Maternal antibodies (MatAb) are passed through the placenta to the fetus by an FcRn receptor on placental cells. This occurs around the third month of gestation. IgG is the only antibody isotype that can pass through the placenta. Passive immunity is also provided through the transfer of IgA antibodies found in breast milk that are transferred to the gut of the infant, protecting against bacterial infections, until the newborn can synthesize its own antibodies.Colostrum present in mothers milk is a example of active immunity. 
Artificially acquired passive immunity is a short-term immunization induced by the transfer of antibodies, which can be administered in several forms; as human or animal blood plasma, as pooled human immunoglobulin for intravenous ( IVIG) or intramuscular (IG) use, and in the form of monoclonal antibodies (MAb). Passive transfer is used prophylactically in the case of immunodeficiency diseases, such as hypogammaglobulinemia.  It is also used in the treatment of several types of acute infection, and to treat poisoning.  Immunity derived from passive immunization lasts for only a short period of time, and there is also a potential risk for hypersensitivity reactions, and serum sickness, especially from gamma globulin of non-human origin. 
The artificial induction of passive immunity has been used for over a century to treat infectious disease, and prior to the advent of antibiotics, was often the only specific treatment for certain infections. Immunoglobulin therapy continued to be a first line therapy in the treatment of severe respiratory diseases until the 1930s, even after sulfonamide lot antibiotics were introduced. 
Transfer of activated T-cells
Passive or " adoptive transfer " of cell-mediated immunity, is conferred by the transfer of "sensitized" or activated T-cells from one individual into another. It is rarely used in humans because it requires histocompatible (matched) donors, which are often difficult to find. In unmatched donors this type of transfer carries severe risks of graft versus host disease.  It has, however, been used to treat certain diseases including some types of cancer and immunodeficiency. This type of transfer differs from a bone marrow transplant, in which (undifferentiated) hematopoietic stem cells are transferred.
When B cells and T cells are activated by a pathogen, memory B-cells and T- cells develop, and the primary immune response results. Throughout the lifetime of an animal these memory cells will "remember" each specific pathogen encountered, and are able to mount a strong secondary response, if the pathogen is detected again. The primary and secondary responses were first described in 1921 by English immunologist Alexander Glenny although the mechanism involved was not discovered until later.This type of immunity is both active and adaptive because the body's immune system prepares itself for future challenges. Active immunity often involves both the cell-mediated and humoral aspects of immunity as well as input from the innate immune system.
Naturally acquired active immunity occurs when a person is exposed to a live pathogen, and develops a primary immune response, which leads to immunological memory.  This type of immunity is "natural" because it is not induced by deliberate exposure. Many disorders of immune system function can affect the formation of active immunity such as immunodeficiency (both acquired and congenital forms) and immunosuppression.
Artificially acquired active immunity can be induced by a vaccine, a substance that contains antigen. A vaccine stimulates a primary response against the antigen without causing symptoms of the disease.  The term vaccination was coined by Richard Dunning, a colleague of Edward Jenner, and adapted by Louis Pasteur for his pioneering work in vaccination. The method Pasteur used entailed treating the infectious agents for those diseases so they lost the ability to cause serious disease. Pasteur adopted the name vaccine as a generic term in honor of Jenner's discovery, which Pasteur's work built upon.
In 1807, Bavaria became the first group to require that their military recruits be vaccinated against smallpox, as the spread of smallpox was linked to combat.  Subsequently, the practice of vaccination would increase with the spread of war.
- Inactivated vaccines are composed of micro-organisms that have been killed with chemicals and/or heat and are no longer infectious. Examples are vaccines against flu, cholera, plague, and hepatitis A. Most vaccines of this type are likely to require booster shots.
- Live, attenuated vaccines are composed of micro-organisms that have been cultivated under conditions which disable their ability to induce disease. These responses are more durable and do not generally require booster shots. Examples include yellow fever, measles, rubella, and mumps.
- Toxoids are inactivated toxic compounds from micro-organisms in cases where these (rather than the micro-organism itself) cause illness, used prior to an encounter with the toxin of the micro-organism. Examples of toxoid-based vaccines include tetanus and diphtheria.
- Subunit vaccines are composed of small fragments of disease causing organisms. A characteristic example is the subunit vaccine against Hepatitis B virus.
Most vaccines are given by hypodermic or intramuscular injection as they are not absorbed reliably through the gut. Live attenuated polio and some typhoid and cholera vaccines are given orally in order to produce immunity based in the bowel.