The camshaft keeps all of the valves working in sequence. But all of this still must always happen at the right time.
Air-fuel mixture must enter at the right time in the cycle and the piston must be in the right place when the exhaust valve opens. The position of the piston is crucial. But what determines that? The crankshaft. It helps to synchronize all this activity.
In one cycle of a 4-stroke engine, from Intake, through Compression, Ignition, Power and Exhaust, how many times does the crankshaft turn? Twice. It makes two revolutions. During that time, what happens to the valves? They open and close once. So the cams must turn through just one revolution. As does the camshaft.
So, in each cycle, the crankshaft turns twice, and the camshaft only once. So the camshaft must turn at half the speed of the crankshaft. One way to do this is with gears.
Suppose one of a pair of gears has forty teeth, and the other, the driving gear, has twenty. When they mesh, the larger one rotates at half the speed of the smaller.
If these gears are separated but linked with a chain, it makes them turn in the same direction, but they still turn at their same speeds.
If the smaller gear is on the crankshaft and the other is on the camshaft, how fast does the camshaft turn, compared with the crankshaft? Half the speed. Just what the system needs.