It seems likely that most horses, carts and other vehicles originally drove on the left, a practice still observed in Britain and its colonies and ex-colonies, as well as several other countries like Japan and Thailand. In fact, in population terms, something like 32% of the world still drives on the left, but driving on the right has become much more popular, particularly in recent centuries and decades. Several African, Asian and Scandinavian countries only changed over to driving on the right since the Second World War, some as late as the 1970s.
The logic of driving or riding on the left (and passing on the right) probably dates back to Ancient Greece, Egypt and Rome. Indeed, before that time, there was little in the way of roads and relatively few travellers making journeys of any distance. When encountering a stranger on the road, it was advisable to have a weapon between oneself and the stranger, which for the right-handed majority meant walking or riding on the left. The practice was even formalized in a Papal Edict by Pope Benefice around 1300AD, who told all his pilgrims to keep to the left, and it became a legal requirement in Britain in 1773.
The reason for the change to driving on the right in some countries is less clear-cut and largely the stuff of legend, but many believe that it started in France. One version has the peasantry using the right side for their own safety in order to avoid the reckless aristocrats who were driving on the left, a majority habit that continued after the Revolution. In another version, Napoleon Bonaparte was left-handed (an assertion that is debatable, to say the least) and he insisted on having his soldiers always travel on the right side of the road (therefore, presumably, passing him on his dominant left side). Either way, the habit became engrained in France, French colonies and French dominated parts of Europe (particularly after Napoleon’s empire-building), although several European countries did not align themselves until as late as the 20th Century.
It is argued that the New World was colonized by the (right-side driving) French, Dutch and Spanish before the English became dominant, so that the habit of driving on the right was already engrained in the continent. This would have been long before Napoleon or the French Revolution, though, and so it is not clear why driving on the right was then the norm. According to others, at the time of American Independence, the French General Lafayette supposedly advised the revolutionaries of the War of Independence that they should enforce driving on the right as the civilized and modern thing to do.
But perhaps a more convincing explanation revolves around the large multi-horse freight wagons which dominated the American roads in the late 18th Century, whose layout required the driver to sit on the back left horse with a lash in his left hand. It was easier for such a vehicle to drive on the right-hand side of the road, so that the driver could ensure there was room to pass and so he could better see the road ahead. Other traffic sharing the road with these behemoths simply adopted the same custom out of necessity.
It was clearly not, however, an organized and logical progression. Canada provides a good example of the complexity and chaos in the process, with its French-influenced right-side drivers and its English-influenced left-side drivers sharing the roads for centuries. It was only in the 1920s, as the volume of traffic increased dramatically and automobiles became more common, that some right-sided uniformity was imposed there (1947 in the case of Newfoundland). To take a European example, as recently as the beginning of the 20th Century, drivers in most of Italy's cities drove on the traditional left side while most of the rest of the country drove on the right!