Kamagra is NOT illegal.
The erectile dysfunction drugs are protected by patents which run out in the US in a few years.
These patents are not enforced in some countries like India. The Indian government believes its citizens have the right to medications without paying the huge costs imposed by Western pharmaceuticals. In India, it is legal for local companies to manufacture drugs under patent elsewhere and sell them cheaply to the local population.
So, when you get those spam emails selling cheap Viagra/Levitra/Cialis, these are generic versions legally manufactured to the same standards as Pfizer or other companies, contain the same ingredient and will have the same effect.
The illegal part is that they are intended for use in India only. The internet sellers are breaking the law by selling them abroad and could be taken to court by the patent holder. But there are so many of them that it is impossible to enforce.