Mustang, so sorry you are going through this, it's the worst, most confusing, most upsetting, bewildering experience most people will ever go through. I'm sure other folks will be by to give you some ideas and some consolation. Not at my best today, but I wanted to let you know, like Tanner, that you've been heard and we care. Please look through the site - you'll see so many people who have gone through things, very similar to what you are now. Your feelings are very normal.
As for your wife's infidelity....well, personally I am not in favor of opposite sex friendship, that's a general statement, because these things often start as friendships and the most component of male-female relationships, of a similar age, is attraction. We may deny it, but I think there's always a little something and the more we engage in it and the deeper we get, the deeper it can go. I think this is something to be avoided generally or we should always try to be aware of the potential. It's something our society tries to deny now and because we do.....people fall into affairs. A sympathetic ear from an appreciative and attractive friend so easily leads to other things. If it is consoling to you at all, I would say I doubt if your wife went looking for this, I think she fell into this mistake of having an opposite sex friend who became a little too convenient. We all have to guard against this, IMO. So I don't think she was actively looking for this or planning it....I think she fell into it and it probably made her feel good about herself in ways she had not experienced perhaps for a long time, and I don't mean physically, I mean emotionally. Often the sex in these relationships isn't even very good, it's what people get out of them emotionally.
I think your wife fell into something that she thought she could handle but she really couldn't and then it's hard to cut off something that makes you feel good about yourself, especially if you haven't for a long time. It sounds like you caught this fairly early, which is a great thing as...the longer if goes on, the deeper the roots go.
I hear what you're saying about your own role in this and I think it's enormous that you are willing to face up and acknowledge that there are problems on your side too that might have weakened her to develop this relationship. While nothing justified cheating, it certainly helps to explain it and is a factor. If you are both willing to look at yourselves and try to work out your problems together, you might be able to get through this. It's very hard though, I think in some ways harder for men because men seem to be more subject to mind pictures.
You will be seeing more responses with more ideas and experiences, we all have our perspectives, and I think you will find them useful and supportive. Just know that no matter what happens, no matter what you decide, there is no wrong answer here, and you have to do what's best for you ultimately. The sense of what that is will emerge as you recover from this shock. Be easy on yourself, take good care of yourself at this time - get enough good food, water, rest, because this is a shock to the mind and body- don't underestimate that.