It's almost the same as asking Why is there ISO graded film?
Couldn't everything done in the camera be done better in post-processing?
Well, yeah. But aperture and shutter speed are forms of exposure control, just as ISO is. Would you ask the same thing about Depth of Field? What's the point of changing aperture when shooting in RAW if I can digitally enhance/change it? Because it's about the photographer's control, really.
if it doesn't affect the amount of photons counted
ISO actually does affect the amount of photons collected and for "correct" exposure the ISO/shutter/aperture all compensate each other. You increase one, another one falls.
When the light hits the sensor, it's still capturing analogue signal/s. After the analogue signal/s leaves sensor's output it goes through an amplifier. This is where the value of the ISO comes in, it's essentially the volume knob for the amplifier.
After this it goes through an analogue to digital converter. It can then be digitally processed, adjusted, compressed or whatever according to your camera's feature functions. Before any of this digital process, it's in the form of a RAW data.
why not keep ISO at 100 and adjust exposure later (aside from in-camera previews)?
Because a low ISO increases the shutter time (in auto mode) and you might want a faster shutter speed to prevent shake/blur or what ever else.
Deleted as I now think it's excessive information that I don't know enough about.
The basic answer is because it hasn't done any processing yet. It goes through the amplifier (that you control with the volume knob) first. RAW is the unprocessed image.