Rivail was born in Lyon, France, in 1804. A disciple and collaborator of Johann Heinrich Pestalozzi, he spoke several languages and taught mathematics, astronomy, physiology, French, physics, chemistry and comparative anatomy. He was already in his early fifties when he became interested in the wildly popular phenomenon of spirit-tapping. At the time, strange phenomena attributed to the action of spirits were reported in many different places, most notably in the U.S. and France, attracting the attention of high society. The first such phenomena were at best frivolous and entertaining, featuring objects that moved or "tapped" under what was said to be spirit control. In some cases, this was alleged to be a type of communication: the supposed spirits answered questions by controling the movements of objects so as to pick out letters to form words, or simply indicate "yes" or "no."
At the time, Franz Mesmer's theory of animal magnetism was popular in the upper reaches of society. When confronted with the phenomena described, many scientists including Rivail pointed out that animal magnetism might explain them. Rivail, however, after personally seeing a demonstration, quickly dismissed the animal-magnetism hypothesis as being insufficient to completely explain all the facts observed. Rivail was determined to understand exactly what was causing the physical effects popularly attributed to spirits.
As an academic with a solid scientific background, Rivail decided to do his own research. Not being a medium, he compiled a list of questions and began working with mediums and channelers to pose them to spirits. Soon the quality of communication with spirits appeared to improve markedly. In 1857 Rivail (signing himself "Allan Kardec") published his first book on Spiritism, The Spirits' Book. It comprised a series of 1,018 questions exploring matters concerning the nature of spirits, the spirit world, and the relations between the spirit world and the material world. This was followed by a series of other books, the most important being The Gospel According to Spiritism, and by a periodical, the Revue Spirite, which Kardec published until his death.
Rivail first used the name "Allan Kardec" allegedly after some spirits with whom he had been communicating told him about a previous incarnation of his as a Druid by that name. Rivail liked the name and decided to use it to keep his Spiritualist writings separate from his academic work.