When two companies undervalue the services that they offer to each other, they pay lower taxes. This is the illegal part.
Businesses are taxed on their net income, not get gross.