unfortunately, bacteria do not leave fossils for us to study, thus scientists use other techniques to surmise how these organisms evolved.
virtually all animal life on earth is dependent on bacteria for their survival as only bacteria and some archea possess the genes and enzymes necessary to synthesize vitamin B12 (a cofactor in DNA synthesis, and in both fatty acid and amino acid metabolism) and provide it through the food chain.
some 3.5 billion years ago essential to life foundation genes evolved including ATP synthase and RNA polymerase, but it now seems also the genes for photosynthesis photosystem II
16S rRNA is key to the production of proteins in all organisms including the 3 early microrganism domains:
Bacteria single celled prokaryote microrganisms with no cell nucleus, which reproduce asexually
Archaea which were single celled prokaryote microrganisms with no cell nucleus, which reproduce asexually, many were extremophiles, and have a high level of horizontal gene transfer and with greater genomic complexity than bacteria, and which have a totally different cell wall to bacteria or eucaryotes, being made up of more chemically stable ether-linked lipids instead of ester-linked lipids.
Eucaryotes have a membrane bound nucleus and perhaps evolved from the joining of Archae to become a cell with organelles
unlike bacteria, eucaryotes are much bigger, have a much bigger genome, can do more with the genome thanks to it having introns and exons, by having switches to turn on or off protein production and even with the same gene can create different proteins which means that the cell can be programmed to take on different functionality as needed and allowed the evolution of multi-cellular organisms into fungi, plants and animals.
the precursors to these 3 domains of microrganisms on earth appear to have evolved 4,280mya when the environment on 320 million year old earth was very hostile and the atmosphere dominated by sulfur rather than oxygen.
the last common ancestor of three 3 domains is thought to be a hyperthermophile perhaps around 3,200mya.
the 1st bacteria thus evolved to use sulfur rather than oxygen and thus were sulfur oxiding and sulfate reducing bacteria
some bacteria evolved to oxidise arsenic (these still live in the oxygen-deplete middle layer of tropical oceans)
Thermotogae evolve and are a taxon of thermophilic, anaerobic bacteria
Aquificae evolve and are a diverse phylum of Gram negative, non-sporing bacteria that live in harsh environmental settings and which are autotrophs (can produce complex organic compounds) and are the primary carbon fixers in their environments.
Fusobacteria evolve and are obligately anaerobic non-sporeforming Gram-negative bacilli.
Eubacteria evolve
3,220mya, divergence of the two main groups of Eubacteria, Terrabacteria and Hydrobacteria as Terrabacteria evolved to survive on land in the harsh conditions on dessicated soil
photosynthetic, oxygen-producing cyanobacteria (“blue-green algae” which belong to the Terrabacteria taxon) along with other microbes such as & archaens form microbial mats which over time become layered on a bed of calcium carbonates deposited from the carbon dioxide rich oceans (limestone) creating stromatolites start to oxygenate atmosphere resulting in the Great Oxygenation Event some 2,400mya and introduced the Proterozoic eon which lasted until 540mya