"It takes two to tango" stems from ballroom dancing. The Tango, while being an enjoyable dance, is one of the dances that cannot comfortably be danced alone (although I believe Fred Astaire has had a history of dancing the tango with a variety of inanimate objects.)
When the phrase is used nowadays, it is usually in retribution to someone trying to blame someone else. When a marriage goes tits-up, for example "it takes two to tango" can point out the fact that it rarely is one person's fault, but also that it takes a certain amount of teamwork and cooperation to make a marriage work.
I have also heard the phrase about sexual and date rape situations - where one person (alledgedly, anyway) didn't realise the other party did not consent to having sex. In this case, the phrase has in the past been used to illustrate that if there was no struggle, it cannot have been rape, "'cause it takes two to tango".
The phrase has further been used to deny cock-ups made by governments - especially for decisions made by the government that weren't protested in any way, yet despised by the people. "Well, we didn't know you didn't want that school knocked down. It takes two to tango - you should have let us know"
The etymology and exact time of origination of the phrase is unknown - the etymological dictionaries and phrasebooks I have consulted - including The Grand Master all drew blanks.