During the Warring States things were very chaotic in China and rulers were struggling to keep control over their people. It was due to these pressures that legalism arose.
Chinese rulers at that time needed to work harder to keep control of their subjects. This necessarily made them act in ways that were harsh and oppressive. In order to justify these actions, they needed a new philosophy. This is where legalism came in. Legalism argued that the people were too ignorant and selfish to act correctly on their own. They needed a strong ruler who could come in and force them to act in ways that would be better for them in the long run. This is similar to how a parent needs to be somewhat oppressive to children for the children's own good.
Because China was chaotic and leaders needed to justify their harsh actions, legalism developed during the Warring States period.