Is there any reference in Buddhism about how our life was before life has appeared on this earth? Were we all in heaven or hell realms?
At the end of a Maha Kalpa, if the world system gets destroyed by fire, all the Brahma, Deva, human and hell realms below Abhassara Brahma realm get destroyed. But once the earth is reformed, beings come back from the Abhassara Brahma realm to populate the earth once more. Agganna Sutta hints that the last time, it was destroyed by fire while the Sapthasuriyuggamana sutta says that this time also it is going to be destroyed by fire. The pattern is: 7 times by fire, 1 time by water and at the 64th repetition, it will be destroyed by air.
"Abhassara brahmas" means Brahmas with streaming radiance. They feed on delight, self luminous and glorious. Abhassara realm is said to be located 5508000 Yojanas away from the human realm. One has to cultivate the 2nd Jhana to the highest degree to be born there. There are two more Brahma realms at the same level. Appamanabha(2nd Jhana- medium degree), Parittabha(2nd Jhana- minor degree).
The lifespan of an Abhassara Brahma is 7 Maha-kalpas since the Abhassara realm also gets destroyed at the 8th time. One day there lasts an Asankya(10 to the power 140) human years.
1 Maha-kalpa = 4 Asankya-kalpa
1 Asankya-kalpa = 64 Antah-kalpa
1 Antah-kalpa = time period it takes for the human lifespan to increase from 10 to Asankya and drop down to 10 again. The increase or decrease said to happen at a rate of 1 year per every 100 years.
Apart from them, there are other beings with Nihilistic(no rebirth, no karma etc.) views who refuse to do good deeds and cultivate Jhana to get into higher Brahma realms. They get caught in the destruction of the world and are born in an Asura hell called the Lokantarika Narakaya. There is no mention as to if they ever get to come back when the new world system is formed. It is said to be situated at the center of three worlds - the human world, the ordinary hells and heavens.
At the center of these three worlds, there is a dark sea of acid water surrounded by rocky mountains. This sea is covered with eternal darkness; no ray of light can reach this place. The creatures of the Lokantarika-niraya hang themselves on cliffs like bats. They are tortured by hunger and thirst as there is no food for them. While moving along the cliff they sometimes come across each other. Thinking that they have come across food, they jump upon each other and start fighting. As soon as they start fighting, they let loose their grip on the cliff and as a result they fall into the sea below and their bodies melt away just like salt melting away in water.
I suggest you take a look at the Dhammapada which is part of the Pali Canon if you are interested in Buddhism.
The Buddha taught that such questions weren't important. He rather encouraged people to focus on the life here and now. There are a few dialogs in the Pali Canon in which Buddha answers his apprentice's similar question with a metaphor.
I would say that our goal is to free ourselves from the notions of "life" and "non-life", from "before" and "after".
"We are scared because of our notions of birth and death, increasing and decreasing, being and non-‐being. Nirvana means extinction of all notions and ideas. If we can become free from these notions we can touch the peace of our true nature.
There are eight basic concepts that serve to fuel our fear. They are the notions of birth and death, coming and going, the same and different, being and non-‐being. These notions keep us from being happy. The teaching given to counteract these notions is called "the eight no's," which are no birth, no death, no coming, no going, not the same, not different, no being, no non-‐being."
No Death, No Fear: Comforting Wisdom for Life by Thich Nhat Hanh 2003 pg 51 – 53