Insider trading can be defined as the purchasing or selling of a publicly traded organization's equity by an individual who has access to material information about that equity, that has not been in the public domain yet.
Insider trading can be described as legal or illegal based on when the insider executes the trade. It is considered illegal when the material information is not in the public domain yet.
In their own words, the United States Securities and Exchange Commission (SEC) explains illegal insider trading as the "buying or selling a security, in breach of a fiduciary duty or other relationship of trust and confidence, on the basis of material, nonpublic information about the security."
Material information can be defined as any insight that has the ability to substantially influence an investor's choice to purchase or sell the stock. Information not in the public domain is information that is not legitimately accessible to the general public.
The subject of legality originates from the Securities and Exchange Commission's effort to keep up a fair marketplace.
An person who has access to insider information would end up having an unfair advantage over other investors, who do not possess the similar access, and might make bigger, 'unfair' benefits than their fellow investors.
Illegal insider trading also involves giving trading tips to others other traders and investors when you have any kind of information that has not been in the public domain yet.