It would not be illegal. In fact the iPhone launched with only Safari.
Because Apple is selling the hardware device, they can decide what software they ship on it. This is not specific to phones, it’s true of all hardware. There’s no feature to load arbitrary browsers onto a PlayStation, for example.