There is a lot of confusion on the web regarding the words illegal and criminal. Many people seem to believe that these words are synonymous and interchangeable but they are not. Especially many people are apparently clueless whether breach of contract is illegal or not.
Short answer: breach of contract is illegal. However, it is often not a criminal offense.
The long answer: illegal means contrary to the law. In modern legal systems the general rule is that all contracts are legally binding – this is known as pacta sunt servanda, i.e. breach of contract has legal consequences. In other words people are party to a contract are by law require to follow the stipulations of said contract and failure to comply might result in civil prosecution.
Of course, there exceptions to this rule and many court cases involving breach of contract focus on whether these exceptions apply to the specific contract or clauses in question.
Around the world legislators have passed laws protecting the interests of third parties or to prevent abuse of weaker parties by stronger parties. These rules restrict the freedom of contract to a certain extent, but do not undermine the general rule that contracts are legally binding.
If a contract contains provisions that are contrary to these laws, those provisions are invalid and illegal. Illegal in this case simply means that such a provision is not enforceable, i.e. one cannot successfully sue another in court for violating an invalid clause. In extreme cases a complete contract might be voided if it contains illegal provisions.
Criminal actions are those activities that are prohibited by law and can be punished by the authorities. By definition criminal offenses are also illegal but the reverse is not necessarily true. For instance usually neither breach of contract nor contracts with illegal/invalid provisions are criminal offenses.
A primary distinction between criminal and civil infractions, is that the former can always be prosecuted by the authorities – if they want to – even if there are no apparent victims. However, a civil prosecution can only initiated by the affected parties. Also a civil conviction will not result in a criminal record and associated consequences.