Kepler was born on December 27, 1571 in Weil der Stadt, near Stuttgart in modern Germany. The family was poor and his parents unfit. His mother was a herbalist and healer, and his father a mercenary soldier who abandoned the family when Johannes was five.
Johannes was a delicate child, especially after contracting smallpox. However he was precociously bright with an amazing flair for mathematics. After grammar school, he was educated at a Latin school, then proceeded to a convent school to study for the Lutheran clergy. The ministry was a good career for an intelligent young man with no family money.
At the University of Tübingen Kepler was an able and keen scholar, particularly in mathematics. Astronomy was then a branch of mathematics and the advanced class studied the Copernican system, but only as an analytical tool. The Earth-centered (geocentric) system was as entrenched in academia as it was in both the Roman and Lutheran churches. Few believed in the reality of the new Sun-centered (heliocentric) model of Copernicus.
Although Kepler was devout, he didn't accept everything his church said. Long after his student days he would write of
a duty to search . . . for the numbers, sizes, and weights . . . for everything [God] has created. . . . For these secrets are not of the kind whose research should be forbidden; rather they are set before our eyes like a mirror so that by examining them we observe to some extent the . . . wisdom of the Creator.
Kepler wasn't ordained after completing his degree, but went to Graz (now in Austria) to teach mathematics and astronomy at a Protestant school.
In Graz he published his first work, sending copies to other astronomers, including the great Tycho Brahe who praised it, despite disagreeing with the ideas. This contact with Tycho would be not only a lifeline to Kepler later, but also provide an essential element of his great work.
In 1597 Kepler married Barbara Muller who was twice-widowed with a young daughter. The marriage lasted fourteen years until Barbara's death.
By the end of the six years in Graz, religious tensions had increased dangerously. In 1600 when Kepler refused to convert to Catholicism, he and his family were banished. Fortunately, he had already realized how precarious his position was and had not only met Tycho Brahe, but they had agreed terms for Kepler to work for him in Prague.
Tycho needed a mathematician to analyze his observations, which he hoped would support his own Solar System model - a compromise between the old geocentric model and new heliocentric one. He was also the Imperial Mathematician to the Holy Roman Emperor Rudolph II, and Kepler was able to collaborate on the preparation of the Rudolphine Tables (updated astronomical tables). When Tycho died suddenly in 1601, Kepler was appointed as Imperial Mathematician.
Since his student days, Kepler had been preoccupied with the Solar System. He realized that in order to test different models, a large body of accurate observational data was needed. There was only one: Tycho Brahe's.
Tycho had been secretive about sharing data with his assistant. But after his death, Kepler took the observational data away. Tycho's heirs, hoping to make money from it, were furious. It seems that Kepler's dedication to praising God by understanding the cosmos had overcome any scruples.
Using the observations, Kepler carried out hundreds of orbital calculations which finally led him to see that it all worked if the orbits of the planets around the Sun weren't circular, but elliptical (squashed circles). He included this in his work De stella nova published in 1606, though it didn't cause a worldwide sensation. Galileo ignored it, Kepler's old tutor disagreed with it, and it wasn't taken seriously as a factual description. But this didn't deter Kepler.
In Kepler's life of illness and financial difficulties, he was bolstered by dedication to explaining the cosmos. But even he must have been tested when his three young children contracted smallpox in 1611 and his beloved elder son died. In the following year he was excommunicated, and his wife died. As did the emperor. Rudolph II had been liberal about religion in his court, but his successor wasn't and Kepler took the children to Linz (also in Austria) where he had obtained official employment as a district mathematician.
In Linz he married Susanna Reuttinger. Their first three children died in infancy, though three others survived childhood.
During this period Kepler's mother was accused of witchcraft, so he went to help with her legal defense. She was eventually freed.
As a court official, Kepler had been partly protected from the Counter Reformation in Linz. However the persecution of Protestants and, eventually, warfare and rebellion made Linz a dangerous place. The family left in 1626, but it also left Kepler with no job or income.
Kepler's final job was in the Duchy of Sagan (now in Poland), but as Europe was torn apart by war, he wasn't getting paid. He died in Regensburg in southern Germany in 1630 as he went to try to collect a debt. The churchyard in which Johannes Kepler was buried was destroyed a year later by an invading army and no one knows where his bones lie.
He wrote his own epitaph, "I used to measure the heavens, now I shall measure the shadows of the earth."
(1) "Biography--Johannes Kepler" http://www.johanneskepler.com/johannes_kepler_bio_001.htm
(2) JV Field, "Johannes Kepler" http://www.gap-system.org/~history/Biographies/Kepler.html