Is it illegal or unethical for a publishing company to pay in exchange for including a co-author? Some weeks ago a company contacted me via email. In summary, they offer to pay you if you include a co-author. They also need you to sign an agreement with your University and them. So, from one side, it seems kind of legal (since in the agreement they state "sponsorship"), but from the other side, these practices, I am afraid could lead to unexpected retractions, due to the likely unethical side of the business. 

Is this kind of service illegal or unethical?
It sounds not ethical to me; if it is legal or not you should ask a lawyer;

Consider the following point: This is definitely at least borderline to scientific misconduct (depending if the co-author actually contributed anything at all), and either you will have to publish in a journal with bad reputation or risk retraction if you publish in any journal caring about it's reputation.

And if your PHD gets delayed (and possibly stalls as a consequence of resulting bad relationships with your team/university), anything which you possibly got from it will turn out not to be worth it.

(As a small side remark: Academic life often forces you to walk the line between ethical and not ethical very carefully. But don't participate in anything like this on your own will)