Historical Background

For all of recorded history, people have been dealing with infectious diseases. During most of that time, we've tried to figure out what causes them, not always with very much success. People had many different ideas about what caused disease. Before the mid-1850s, most people thought that diseases were spread by a "miasma", meaning nasty-smelling bad air. Some people had other ideas, though. Writings survive from ancient India and Greece describing person-to-person transmission of infectious disease, and Persian and Arab thinkers guessed that diseases might be spread by invisible particles of some kind during the Middle Ages.

By the late 1600s, Anton van Leeuwenhoek had become the first person we know of to see and scientifically describe microorganisms like bacteria and yeast, and it didn't take long for doctors and scientists to guess that some of these microorganisms might cause diseases. By the late 1850s, germ theorists like Louis Pasteur had begun to prove this, and by the 1900s doctors had begun to finally identify the bacteria that cause many infectious diseases. The first viruses were discovered in the 1890s, although it wasn't until the 1930s that people truly figured out what they were and how they worked.

While infectious diseases can be caused by fungi, or parasites, these don't usually end up spreading far enough or quickly enough to cause pandemics. Malaria, for example, is a disease caused by protozoan parasites from the Plasmodium genus, and even though it kills about 400,000 people every year, it isn't a pandemic disease, because it is only prevalent in tropical regions. Bacteria and viruses, on the other hand, can affect people in almost any environment, and are responsible for most of the true pandemics in human history. Some examples of important historical epidemics and pandemics include:

The Plague of Justinian, 541 AD
Believed to be caused by the same bacterium as the later Black Death, and named after the Eastern Roman emperor Justinian, who contracted the disease (and survived). Killed somewhere between 25 and 100 million people in Europe, North Africa, and western Asia.
The Black Death, 1346-1350
Now thought to have been caused by the Yersina pestis bacterium, the Black Death started in eastern Asia and spread west to Europe and North Africa, killing anywhere from 75 million to more than 200 million people along the way, including anywhere from 30% to 60% of Europe's population at the time.
Cholera
Caused by the bacterium Vibrio cholerae, cholera has caused several major epidemics in various parts of the world since the early 1800s, killing perhaps 50 million people throughout the world. After it was discovered in the mid-1800s that Vibrio cholerae spreads through drinking water, cities in western Europe and North America eventually started improving their sanitation systems, and the last two cholera pandemics, in the twentieth century, have mostly affected areas in the developing world without safe drinking water systems.
Smallpox
Caused by the variola major and variola minor viruses, smallpox might have caused the Plague of Athens in 430 BC, and became endemic in Europe by the Middle Ages. It spread to the Americas with European colonists, where it killed many millions of Native Americans, almost completely depopulating some places. The first vaccines ever discovered were against smallpox, and a successful vaccination campaign in the 20th century managed to completely eradicate it by the 1970s.
"Spanish" flu (H1N1), 1918-1920
Spread throughout the world with the help of World War I, the H1N1 influenza pandemic killed between 50 and 100 million people worldwide. The H1N1 variant of the influenza virus originated in pigs, which is why it's also called "swine flu". Despite the common name, it probably didn't originate in Spain, and may have come from elsewhere in Europe or from the United States (where the first confirmed case was found).
"Asian" flu (H2N2), 1957-1958
Originating in southwestern China, the then-novel H2N2 variant of the influenza virus, which infected humans from birds ("bird flu"), quickly spread throughout the world. Fortunately, a vaccine was produced relatively early, and helped to contain the pandemic. About a million people died.
"Hong Kong" flu (H3N2), 1968-1970
Caused by the H3N2 influenza virus, which was related to the earlier H2N2 variant, the 1968-1969 flu pandemic originated in the summer of 1968 either in Hong Kong or nearby on the Chinese mainland, and quickly spread throughout the world by 1969. Between one million and four million people were killed throughout the world before most people built up some immunity, and the virus is still around as a strain of ordinary seasonal flu.
"Swine" flu (H1N1), 2009-2010
Probably originating in pig farms in Mexico, an outbreak of the same H1N1 influenza virus that caused the 1918 "Spanish flu" quickly spread throughout the world and reached pandemic status in early 2009. This pandemic was fortunately not nearly as severe as the original 1918 one, and "only" between 150,000 and 575,000 people or so died.
Human Immunodeficiency Virus (HIV/AIDS)
After jumping from chimpanzees and gorillas to humans sometime in the early 1900s, the Human Immunodeficiency Virus (HIV) eventually grew to a major pandemic in the 1980s and 1990s, particularly affecting sub-Saharan Africa. This pandemic is still ongoing, and a total of about 32 million people have died of it so far.
COVID-19, 2019-?
Related to the viruses that caused the earlier SARS and MERS epidemics, the SARS-CoV-2 virus has killed over 750,000 people at the time of writing. This pandemic is still ongoing and changing rapidly, but has already been more disruptive to human society than any since the 1918 H1N1 pandemic.