Transition from behaviorism to cognitivism

clearly present the transition from behaviorism to cognitivism. Why did that happen? Why only in the middle of 1900s? Why not before?