If you live in the relatively food abundant environment of another cell, then you don't have to be able to digest every single food source in existence, of defend against a wide range of predators.
So because DNA replication is a key limiting factor of bacterial replication time, you just reduce your genome to a minimum.
And likely you also want to be as small as possible to evade the host's immune system.
Power, Sex, Suicide by Nick Lane (2006) section "Gene loss as an evolutionary trajectory" puts it well:
One of the most extreme examples of gene loss is Rickettsia prowazekii, the cause of typhus. [...] Over evolutionary time Rickettsia has lost most of its genes, and now has a mere  protein-coding genes left. [...] Rickettsia is a tiny bacterium, almost as small as a virus, which lives as a parasite inside other cells. It is so well adapted to this lifestyle that it can no longer survive outside its host cells. [...] It was able to lose most of its genes in this way simply because they were not needed: life inside other cells, if you can survive there at all, is a spoonfed existence.
and also section "How to lose the cell wall without dying" page 184 has some related mentions:
While many types of bacteria do lose their cell wall during parts of their life cycle only two groups of prokaryotes have succeeded in losing their cell walls permanently, yet lived to tell the tale. It's interesting to consider the extenuating circumstances that permitted them to do so.
[...]
One group, the Mycoplasma, comprises mostly parasites, many of which live inside other cells. Mycoplasma cells are tiny, with very small genomes. M. genitalium, discovered in 1981, has the smallest known genome of any bacterial cell, encoding fewer than 500 genes. M. genitalium, discovered in 1981, has the smallest known genome of any bacterial cell, encoding fewer than 500 genes. [...] Like Rickettsia, Mycoplasma have lost virtually all the genes required for making nucleotides, amino acids, and so forth.