Buddha said that every living creature is subject to cause and effect.My question is what were we paying for in our first life?Well let me put forward like this,the first living creature after the earth was created was a bacteria and life originated in the sea which is a well established fact,then what was the bacteria paying for?Why didn't it take birth as a human?Also Homo sapiens came way after the extinction of many species?Then wht did the animals like dinosaurs take birth and why did the species get extinct?Doesn't Buddha's karma theory get debunked in this case?
Well let me put forward like this,the first living creature after the earth was created was a bacteria and life originated in the sea which is a well established fact.
You're missing a few important key words. Correction: "it's a well established OBSERVABLE fact TO DATE". Therefore, resorting to what we know as of now, given all the scopes, limits, and constraints of our senses to observe and capture fact/truth, is nowhere near sufficient to jump to conclusion that the law of causation is incomplete. And also as others already mentioned, there's no such thing as a "first life".
From an inconstruable beginning comes transmigration. A beginning point is not evident, though beings hindered by ignorance and fettered by craving are transmigrating & wandering on. Long have you thus experienced stress, experienced pain, experienced loss, swelling the cemeteries — enough to become disenchanted with all fabricated things, enough to become dispassionate, enough to be released." ~~ SN 15.3 ~~
OP: Buddha said that every living creature is subject to cause and effect.
Not only sentient beings, everything unless Nibbana is subject to cause and effect.
OP: My question is what were we paying for in our first life?
There is no such thing called "first life". We all have been gone through an endless cycle of birth, decay, and death. We are continuing that cycle until we attain Nibbana. Saṃsāra is a cycle. Can you point out an starting point of a circle? You cannot because there's always a point before the point you point out. This is well explained by Buddha in dependent origination.
Once Buddha said, "From an inconstruable beginning comes transmigration. A beginning point is not evident, though beings hindered by ignorance and fettered by craving are transmigrating & wandering on." (Assu Sutta - SN 15.3)
OP: Well let me put forward like this,the first living creature after the earth was created was a bacteria and life originated in the sea which is a well established fact,then what was the bacteria paying for? Why didn't it take birth as a human?
Even-though it was the first appearance on this earth for the first bacteria on this earth, it had been gone through endless cycles of birth, decay, and death in many other planes of existence before the earth was formed. Neither formation of the earth nor the so called Big Bang can be considered as the start of this universe or life. There were endless Big Bangs and Big Crunches. If you need Sutta explanation on "how the earth was created first?" and "how first plants appeared on earth?" and "how earth will be destroyed?" then please read Aggañña Sutta (DN 27) & Sattasūriya Sutta (AN 7.66).
By reading my above explanation one may think that the earth existed before we first appeared and the earth will remain after we died. It is true if we speak conventionally. What actually happen is there's no such long lasting earth. The outer world arise, exist, and, cease momentarily with us. In other words these five aggregates arise, exist, and, cease momentarily.
Science and Buddhism don't go hand in hand yet. But some facts taught in Buddhism which were rejected by Scientists have been proven to be correct recently. (Many of those are explained by Bhante Samahita in this video: Early Buddhism, Quantum Physics, and Relativity). I suppose science should be further developed to understand what is taught in Buddhism. So don't try to understand what is taught in Buddhism with the help of Scientific facts.
If we take a moment in one's lifetime he/she/it accompanied by his/her/its own deeds/kamma of past and may receive the fruits of them with the aid of a resultant consciousness at that moment. That's why Buddha said, "Kamma-s·sak·omhi, kamma-dāyādo kamma-yoni kamma-bandhu kamma-paṭisaraṇo. Yaṃ kammaṃ karissāmi, kalyāṇaṃ vā pāpakaṃ vā, tassa dāyādo bhavissāmī ti." (English translation: I am my own kamma, I am a heir to my kamma, I am born [in this life] from my kamma, I am the kinsman of my kamma, I am protected by my kamma. Whatever kamma I shall do, good or bad, I shall become their heir.)
So the first bacteria on earth was definitely receiving the fruits of its past kamma.
Note: This is how I understood. I may be wrong but not Dhamma.
My question is what were we paying for in our first life?
The idea of "paying" for something seems to me a projection of human society -- e.g. according to modern civil law you pay a merchant for goods you buy, you pay a labourer for their service -- or in criminal law you might say that a criminal "pays for" their crime by being punished.
That's not a good metaphor for cause and effect in the natural world -- when snow melts, or when a drop of water evaporates, or when a cloud rains, I'd say that's "cause and effect" but I wouldn't say that's "paying for" something -- it's a natural consequence of the water's existing within changing (impermanent) atmospheric conditions.
Anyway I don't think "we" have a "first life" (see SN 15.3 quoted in @santa100's answer). If or whenever we have a life, that's a consequence of being "born" etc.
Doesn't Buddha's karma theory get debunked in this case?
I don't think so, because IMO the karma theory isn't the the same as (isn't trying to explain) the theory of the evolution of species (including bacteria)
Theories have a limited scope and use.
For example the idea of "paying" for actions is more-or-less useful in describing some aspect of human society -- even then it is not very/widely useful, if it's true that the best things in life are free (a lot of human society is neither "commercial", nor a matter of criminal "justice").
But the idea of "paying" isn't very useful in describing the state changes of water over time (though you can try to force the theory to fit by stretching the analogy, by pretending that heat is "paid" from one place to another -- "conservation of energy" and so on).
I think that Buddhism defines "karma" as "intentional action" -- so I'm not sure that (the theory of) "karma" is applicable to bacteria at all, although theories about "cause and effect" are.
I think the Buddha's karma theory says something else, something like, "You should try to be ethical and wise, to avoid causing suffering for yourself and others". This is especially applicable to human life -- maybe all "sentient beings" -- hard to see how it applies to bacteria though. And I think that the theory of karma is meant to be applicable to (i.e. useful description of) this life -- not to some hypothetical or non-existent first life -- perhaps approximately as described in this answer.
If you're interested, there is a sutta which seems to describe the origin of species, saying that the human species evolves as a result of craving food. According to this answer, though, some people don't interpret it literally:
the Aggañña Sutta is “an extended satire on brahminical ideas, full of parody and puns… As a debunking job I think the sermon is serious: its main aim is to show that the class system is nothing but a human invention”
Don't ask "whose suffering?", "whose craving?", "whose ignorance?", "whose rebirth?"
Remember sabbe dhamma anatta - all phenomena is not self. There is suffering, not my suffering or your suffering. There is craving, not my craving or your craving. There is ignorance, not my ignorance or your ignorance.
One day, our Sun will grow hotter, expand and eventually explode. This will happen at least 5 to 8 billion years later. All life on Earth will eventually be destroyed.
But just as how life started on Earth through chemical interactions, it can start again somewhere on another planet. Perhaps it already has. With the start of life, followed by evolution, eventually, the mind will reemerge, and with it, ignorance will also return. With ignorance, we would have the birth, death and rebirth of sentient beings.
Rebirth here is the rebirth of ignorance, rebirth of the individual existence of a sentient being, and the rebirth of suffering. Not the rebirth of a specific countable and distinctively identifiable individual self that is permanent and standalone - that would violate the fact of anatta.
This is why most suttas in SN 15 state "from an inconstruable beginning comes transmigration. A beginning point is not evident ..."
Also please see this answer about karma.