Illegal Goods are items that are prohibited in a location by the ruling Minor Faction. Which items are prohibited can be checked on the System Map, by selecting a Starport and reading the Prohibited list in the sidebar. If you are carrying illegal goods, the Illicit Cargo indicator on the dashboard will light up, and in the Cargo tab of the left panel the prohibited items will be marked with a label reading Illegal.
Legality of items differs between each system, but is generally constant depending on jurisdiction and security level. Be careful on long distance trips when moving goods that may be illegal (such as drugs) as a system on the way may consider something illegal and fine you. Anarchy systems allow all items, therefore they are an ideal place to buy/sell illegal goods to trade elsewhere.