Foam is a petroleum based product and it is made from different chemicals,it also has to be flame retardant, that is the law, this adds a another chemical to the foam.
The foam smell occurs through a reaction called off - gassing. It is the same as dry cleaning products, new paint, some adhesives, new products like cars and some furniture. the smell happens when VOCs (volatile organic compounds) break down (this process is called off- gassing.)
Odour from off gassing can be unpleasant but not harmful. In the worst case scenario from some rare feedback over the past 20 years perhaps some nausea.
Off - gassing has to take place somewhere either in the factory or in the home sometimes depending on where the foam is cut from the block it may need longer to off-gas (ventilate)
Manufacturers are reluctant to leave leave cut mattresses open in a factory environment for too long to ventilate, because of maintaining hygiene and the foam going yellow as it oxidises. Oxidisation does not in any way affect the performance of the foam, but does not look nice when it arrives as a new product in your home with yellow shading.
Clearly as a parent you would see a chemical smell in your cot mattress as a risk to your baby, which is understandable. Being honest, yes, VOC's in quantity have been classed as potential carcinogens, but not one study has shown that foam is in anyway toxic. It is probably one of the most widely used safest products across the manufacturing industry.
If your cot mattress arrives and it has an unpleasant smell remove the covers and put it in a well ventilated room or garage. There is little point in putting it in a room to ventilate with the windows closed, it could make the room smell. 24 to 48 hours should be enough time to off-gas, it is rare that it takes longer. however we have had feedback from one customer that it took a week!
Natural mattresses have a newness smell but very different to that of foam.