I can't tell you why your wife did this, but here's my perspective after a fifteen year marriage to a closeted lesbian with whom I had three kids. I blew the cover off her same-sex affair four years ago, and we divorced a year later.
I'm convinced that in-denial people who perpetrate this type of hideous fraud have a fundamental personality disorder, usually narcissism with a sprinkling of sociopathy. At many levels, they are fundamentally uncomfortable with themselves because of family, religious or societal homophobic views. They are fundamentally uncomfortable with themselves, and they try to fake a heteronormative life. They are actors on the stage of life, and we are their unwitting co-stars in a play that only they know they are staging. And unfortunately, not even the best actor can prevent themselves from breaking character on that stage.
They have no excuse for doing this. They could have chosen many other paths -- staying single, staying in the closet, moving somewhere with more accepting LGBT+ views. Choosing to perpetrate this kind of fraud requires a massive psychological defect.
I'm sorry you are dealing with this. For me, things became easier once I realized that the woman I married was a character portrayed by a skilled actress. That character never actually existed in the real world.