It's been legal since two individuals were allowed to enter a contract with one another. Furthermore it doesn't become illegal for someone to make disparaging comments or even breach an NDA. You don't go to jail for that. There are however consequences to those statements which were mutually agreed upon in a signed contract.