The Bitcoin wiki gives full details[1], but tldr, 51% attack breaks most elements of the blockchain (reverse attacker's transactions => double spending, prevent transactions from getting confirmation, prevent valid blocks originating elsewhere) but doesn't allow the attacker to arbitrarily rewrite history.
As far as "hasn't this already happened", some of the mining pools in aggregate have had or presently could combine to get 50+% of the Bitcoin mining power[2], but to perform the attack requires active coordination from all pool participants. If an attack like this were launched, it would be obvious to anyone viewing the blockchain, likely destroy the value of Bitcoin, and hence their investment, so is economically not a good idea for them.
[1]: https://en.bitcoin.it/wiki/Weaknesses#Attacker_has_a_lot_of_...
[2]: https://blockchain.info/pools