In analog days, the shutter let light in for some determinant time. That caused the film to be exposed for that duration. But in the digital age, why doesn’t “setting the shutter speed” just tell the internal computer how long it should record data from the sensor? What good does it do to actually open and close a physical shutter?

Most of the SLR film 35mm cameras had shutters that opened by a mechanism that had two curtains travelling horizontally, one ahead of the other. This made a slit of variable size that exposed the film in relation to the size of the slit-ie. a larger opening was a slower shutter speed. This allows for some photographic effects, but I forget which. The shutter opens after the mirror goes up.

I tried to think of an answer to your question and then I looked on line and found this explanation, which I never would have thought of, as it is out of my range of knowledge:

Here’s the takeaway from Steves-Digicams that my brother linked to in the comment above:

—

Most digital SLR cameras that use a mechanical shutter, however, use the mechanical shutter to control the amount of charge accumulated on the sensor as this simple mechanical device can be used to simplify the circuitry on the sensor itself thereby generally improving image quality and reducing noise.