In a nutshell, plugs and sockets differ from region to region and even country to country because, at the time they were being developed, no one really saw any reason to make them all the same.
First, a little history. When electricity was first introduced into homes and businesses, it was primarily for powering lights. Early devices and appliances that ran on electricity had to be wired directly into a building’s electric system. It was a little inconvenient—you couldn’t easily move, say, a lamp, from one room to another without wiring it in again—and a potentially hazardous task for most people to attempt.
Starting in the 1880s, several inventors patented variations on a connector that allowed the cord from an appliance to be screwed into a lightbulb socket for power. (Thomas Edison was not one of those inventors, and that was a “curious oversight” on his part, says historian Fred E. H. Schroeder, since he “anticipated almost everything that might relate to the incandescent light bulb and its applications.") These connectors made it much simpler and safer to connect an appliance to power. Since they screwed into the socket, dropping the appliance or pulling too hard on the cord meant you might damage the device, the cord, or the socket.
In the early 1900s, inventor Harvey Hubbell improved on the idea with his Separable Attachment Plug. The plug had an inner connector screwed into the light socket and an outer connector (attached to an appliance by a cord) that plugged into that via two prongs and could easily be popped in and out. It was the ancestor of the modern two-prong plug and socket.
Other inventors soon started coming up with improvements and safety features for this ancestral plug (like a third prong for grounding, insulation for the prongs, and plug shapes that ensured the plug was connected to the socket properly). Just like there’s more than one way to skin a cat, there’s more than one way to design a safe, convenient plug. All over the world, inventors, tinkerers, and engineers approached the task with their own spin, and we wound up with a bunch of different plugs and sockets that all started with the same basic idea, but were designed in very different ways.
At the time, there was no real reason they shouldn’t have been different. The world wasn’t as connected as it is today and electrical appliances weren’t as ubiquitous. International travel wasn’t convenient or attainable by most people, and even those that could hop across the pond probably weren’t going to be lugging a lamp or a fan with them. It didn’t really matter if someone half a world away could use the plug you were developing, so different countries and regions did things their own way and developed plugs and sockets according to local and national standards that often differed very much from each other.
By the time travel and appliance portability were at the point where standardization made sense, electrically wired homes and electric appliances were widespread, and switching to new plugs and sockets was an expensive proposition—which is not to say that a global standard doesn’t exist and a switch over can’t be done. In 1986, the International Electrotechnical Commission unveiled a “universal plug,” known as a Type N plug, that they hoped would become a widespread standard. So far, though, only Brazil and South Africa have adopted the design for their plugs and wall outlets.
For the foreseeable future we’re stuck with the hodgepodge of plugs and sockets that we have. If you want to see what different countries use, see here and here. And if you’re wondering if one plug is actually better than the others, Tom Scott makes a pretty good case for the British design.
If you’re abroad, it’s not just the plug and socket that will be different, but possibly the voltage and frequency of household electricity, which differs from region to region. Even if you have a plug adapter for when you travel, the voltage disparity means that your gadgets might not work as well, or could become damaged. The voltage split has its roots in the “War of the Currents,” which is an interesting story.