Gregor Mendel was an Austrian monk who bred pea plants in his monastery garden in the 1850s and 1860s. Peas grow quickly, give many offspring and have clear, contrasting features such as tall or short stems. Mendel controlled which plants were crossed by moving pollen by hand, so he knew the parents of every plant.
When he crossed pure-breeding tall plants with short plants, all the offspring were tall. When he crossed these offspring with each other, short plants appeared again, in a ratio of about 3 tall to 1 short. He had counted thousands of plants and used mathematics to find the pattern. He concluded that features are controlled by separate factors, one inherited from each parent, and that some factors are dominant while others can stay hidden, or recessive. These factors are what we now call genes.
Mendel published in 1866, but his ideas were ignored until 1900. Nobody knew about chromosomes, DNA or meiosis, so there was no known mechanism. Many scientists believed in blending inheritance, where offspring are a mixture of their parents, and this cannot explain a hidden feature coming back. Using mathematics to study living things was also unusual at the time.