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 for "correct" exposure. The ISO/shutter/aperture all compensate each other. You increase one, another one falls.
Consider you have a consistent light source and fixed aperture/shutter speed values. Changing the ISO will not change the amount of light/photons captured. However, the resulting image will be either over/under exposed.
Example:
ƒ/5.6, 1/125 shutter speed, ISO 100
If you increase the ISO but still want the same exposure, you'll have something like:
ƒ/5.6, 1/250, ISO 200
or
ƒ/2.8, 1/125, ISO 200
In both cases, you've increased the ISO while decreasing the amount of light/photons captured.
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.