My two cents is the biggest factors were the keto and the stress. A low carb, high fat diet does not traditionally feature intact plant cell walls, or what we otherwise know as "fiber". There are literally thousands of different of variations of "fiber" of which we have catalogued only a few, but these structures feed the microbiota in your gut. And they really do depend on fiber in a profound way.
Without this fiber, they tend to starve and adjust to feed on the epithelial lining of your gut. It also gives an opportunity for the pathogens in your gut to "takeover", especially when paired with the stress since most of the "beneficial" microbes will tend to die off.
When you read stories of people who got an autoimmune problem, there's almost always a period of severe stress prior to it. My working hypothesis is this impairs the immune system which is what keeps the pathogenic bacteria in check through several mechanisms (pathogen-associated-molecular-pattern detection or PAMPs for instance).
Through much, much trial and error and a lot of scientific article research, I've found the most consistent way to restore microbiota ratios is with Vitamin D, followed by a clinically tested probiotic like Visbiome, followed by Kefir. The Vitamin D alone at moderate to high doses will get you very far, although it doesn't necessarily restore diversity (since Vitamin D in of itself does not contain any microbes) but it helps shift the balance of microbes through a variety of biochemical functions.
Vitamin D also helps with gum disease in my experience and in a way no other supplement or product has so far. Highly recommend and you don't even have to take a high dosage to see it for yourself. You just have to be consistent.
One last thing I'll say is that for whatever reason taking the supplement seems to work better than exposing yourself to sunlight, which is unusual, but there may be something about the biochemical pathway Vitamin D takes when consumed as a supplement as opposed through the cholesterol-synthesis that happens with UVB.