The main reason slack is needed is the rear suspension of the bike. In a "perfect" setup, the axis of the rear swing-arm and the final drive of the engine would be one and the same. This is not normally possible so a compromise must be made. In this diagram, you can see the two different axis.

Because of this, on a typical street bike, the chain has more tension when you are sitting on the bike and the rear suspension is slightly compressed. A common mistake is to make the chain tight when it's on a stand and then ending up with a chain that is way too tight once you're riding.
Chain and suspension geometry is a pretty complex topic. The diagram above is from this site which also has a lot more technical information.
https://www.sportrider.com/more-fun-geometry#page-3
Another reason for the slack is the physics problem of why you can never pull a rope across two points to make it perfectly straight. Gravity is going to make the chain sag and appear to have some slack. The amount of force needed to make the chain appear to be tight and slack free would be detrimental to the wheel and final drive bearings. There's no benefit to tightening out all of the slack - only increased wear.