The primary purpose of the IMDG Code is to ensure the safe and secure transport of hazardous materials, which include toxic substances, across international waters. It aims to protect the maritime environment and human health by minimizing the risks associated with accidental releases or exposures to toxic chemicals during transit.