Because all the other chocolate makers in the world were sending in spies dressed as workers to steal Mr. Wonka's secret recipes.
9 seconds sound clip from the Willy Wonka & the Chocolate Factory movie soundboard.
You can hear this line at 00:09:12 in the Blu-ray version of the movie.
Quote context
[...]
- He was standing right behind me looking up at the factory.
- Just before he left, he said: 'Nobody ever goes in, and nobody ever comes out'.
- Not since the tragic day that Willy Wonka locked it.
- Especially Slugworth. Oh, that Slugworth, he was the worst.
- Finally, Mr. Wonka shouted, I shall be ruined! Close the factory.
- And that's just what he did. He locked the gates and vanished completely.
- And then suddenly, about three years later the most amazing thing happened.
- The factory started working again, full blast.
[...]