Patents. Every fucker who comes up with “one universal screw type” wants a cut of every one made.
Different types have different advantages and disadvantages.
Slot can be opened with stuff that isn’t screwdrivers (keys, coins, etc). They can take more torque than Phillips and are cheap to make. They kind of suck to use though, the screwdriver/bit likes to slip off.
Phillips self-centers the bit, and is pretty tolerant of wrong-sized driver for the screw. It strips easily though.
Torx, square and Allen are more expensive to make and require the correct size driver, but they’re higher torque and the driver doesn’t slip out of the screw.
Building on this, screw designs have evolved with technology.
Pozidrive looks like Phillips, but was designed so that the driver slips out without damaging the head if too much torque is applied. It was useful for early car assembly robots, which couldn’t control the amount of torque they applied. They’d just apply as much torque as possible and the head would slip at the right point.
As the technology improved, it became possible to control the torque the robot applied. That lead to Torx head screws. They’re designed to maximise the torque that can be applied without slipping. In modern car assembly, the robot tightens the screw to the designed torque automatically.