Sounds like your wife is moody and feeling insecure. Have you ever talked to her about her feelings? Does she have mood swings?
Manic behavior followed by depressive withdrawl could be a symptom of biochemical imbalance. Manic behavior often comes out as uninhibited sexual expression. That might have been the cause of her previous affairs.
I encourage you to talk with her about her feelings, her fears, how she perceives the world. If she is insecure and afraid, she may be attempting to brazenly hide her fears, but in doing so, she may be creating the outcome she fears. Acknowleging fears and sharing them with a loved one that you trust is the most effective way of handling them.
You say that you have been best friends, perhaps you need to go back to that and talk to each other -- really talk. Let your wife share her feelings, let you share yours. Your friendship may help you through a tough spot in your marriage -- and your marriage and sex life may end up stronger because of it.
Even little ones pick up on their parents' emotions. Staying married for the kids is never good, but staying married because you still love each other and can forgive mistakes will be good for your kids. It teaches them that marriage is something to work at. When they grow up, they will be more likely to have stable marriages if they see you work through this difficulty and emerge happy.
I've been married 20 years. My marriage is complicated and I certainly can't say that we'll be married another 20 years. I've noticed that the worst times involve us not talking about something.
Thus far, whatever it is, when we talked about it, we have been able to work through it together. I know that I will not find what I'm looking for outside my marriage. I need to find it within myself.