Clown fish lay eggs near a sea anemone because the anemone has urticant or irritating substance that can affect clownfish´s predator and theirs eggs.
Explanation:
the anemones provide eggs with protection from predators, they have nematocyst with a paralyzing effect in theirs prey. However clownfish and the eggs are safe because evolve in harmony with the sea anemones. In this alliance the clownfish defends the anemone too.