And why R is before D, making the driver behind you think you are backing up?
You want the drive gear to be as far away from the reverse and park gears as possible. On not-very-much-older automatics it was entirely possible to shift from drive to reverse or park while in forward motion, which annihilated the transmission and was very dangerous to the passengers. A lot of modern cars have a locking mechanism that engages to prevent this but that can fail of course. Having the order like this is not only safe, but it is consistent across vehicles, making driving a new vehicle east to pick up.
In the early days of automatic transmissions reverse was the last position or at the bottom. It was changed due to a government regulation.
Other comments have covered the P-R part. I’ll talk about the D-N part.
You want the neutral to be next to the drive when you drive on icy roads.
If your car starts to slip and you are going down a hill, you want to remove any torque on your wheels and let them run free (aka neutral). This allow better handling and let you retake control faster.
Most car will have the D and N in a line (while R and P will require somewhat of a sidestep) so in case of an emergency, you can slam the stick without thinking and it should move from D to N without risk of hitting R accidentally.
Read Ralph Nader’s unsafe at any speed. It explains this topic in some detail. Accidentally shifting into drive is a lot less likely with the PRNDL pattern. Also before that pattern shift sequences weren’t standardized leading to driver confusion.
so, it starts from the order Reverse-Neutral-Drive, which makes sense, one-direction | no-direction |opposite-direction.
now we have to add park, well you could put it right next to drive, but it’s not a good idea as it could make it easy to accidentally shift to park while driving which isn’t a good thing, so the only other reasonable place is before reverse
also this makes it so after drive you can have L or S, which are just froward with a slight twist