The most important factor seems to be the relative dominance of different types of animal-drawn carts and wagons. Most people are right-handed, which leads to a natural tendency to favour one side of the road or another depending on the means of transportation being used.
Many people who discuss this topic focus their attention on the role of wearing swords by mounted knights and samurai in the middle ages. However, the role of the sword may have been exaggerated by modern romantic ideas. Medieval road traffic would have been dominated by commoners on foot and transporting goods in carts, who would not have worn swords. The only people who would have routinely worn swords would have been the aristocracy and their troops, and when their wagons rolled, right-of-way was surely determined by rank, with commoners scattering into the ditches on either side of the road equally. Medieval knights were relatively few and far between on the roads, and even if they preferred to pass one another in a certain manner (probably more for ceremony and to show respect than out of a real perception of danger) the protocols they followed would not necessarily have translated into rules applicable to the entire population.