In this paper we estimate the number of habitable planets in our Galaxy over cosmological time scales. This number can be derived from the planet formation rate (PFR) of Earth-like planets and the convolution of this value with the probability of being habitable. The PFR is calculated from the star formation rate (SFR) with the help of a so-called Goldilocks problem. The probability that an Earth-like planet is in the habitable zone (HZ) is estimated with the help of our Earth system model. In order to calculate the HZ an integrated system approach is used, taking into account a variety of climatological, biogeochemical, and geodynamical processes. Habitability is linked to the photosynthetic activity on the planetary surface. We find that habitability strongly depends on the age of the stellar system and the characteristics of a virtual Earth-like planet. There was a maximum number of habitable planets around the time of the Earth’s origin and interstellar panspermia was most probable at that time. Furthermore, we discuss our results in the framework of the so-called principle of mediocrity.