Many proteins including toxins are produced in their inactive form. They become activated only when exposed to specific environmental conditions as for example specific pH, temperature etc. The bacteria does not get killed due to tire action of protein. Thus it is advantageous to the bacteria producing it.