Cosmological aspects of planetary habitability