The most globally widespread phonetic scripts (abjads, alphabets, abugidas, etc.) can be traced back to Proto-Sinaitic, which originated around 1900 BCE among Semitic peoples living near Egyptian colonies in the Sinai peninsula. This answer will focus on that family of scripts, whose modern representatives include Latin, Cyrillic, Greek, Hebrew, Arabic, Fidäl, and even Devanagari, Tamil, and Thai, among many others.
Proto-Sinaitic was an abjad (an alphabet without vowels) directly inspired by Egyptian hieroglyphic script. All P-Sinaitic letters have a corresponding hieroglyph, though the phonetic values don't typically match. Egyptian could be written and read either left to right OR right to left; you read it in the opposite direction the characters are facing. P-Sinaitic inherited this variable writing direction.
Around 1000 BCE Proto-Sinaitic gave rise to the Phoenician script which tended to be written RtL, but on occasion also in a manner called boustrophedon (Greek for "as the ox plows") wherein the text was written alternating the direction with each line in a zig-zag patter. As in Egyptian, you could identify which way to read a line because the characters would be flipped. The Phoenician alphabet later evolved into the Aramaic alphabet over the course of the 10th-9th centuries BCE, which had a fixed RtL written direction; the modern Hebrew, Syriac, and Arabic alphabets - all written right to left - descend from this branch of the family.
The Phoenician alphabet provided the basis for early Greek scripts around 750 BCE. Early forms of the Greek alphabet and the Italic scripts these inspired (Etruscan, Archaic Latin), etc. were commonly written in the boustrophedon style, though by 500 BCE they had all more or less settled into being written LtR. As a result, the modern Latin, Greek, and Cyrillic (Greek-derived) alphabets are also written LtR.
Back in Asia around the 4th to 3rd centuries BCE, the Aramaic alphabet also provided the basis for the Brahmi script, which in its earliest forms could be written either RtL or LtR but quickly settled into LtR only. Brahmi is the common ancestor of nearly all the indigenous scripts of India and Southeast Asia - all written LtR.
One more interesting change in directionality happened in Central Asia... The RtL Aramaic script gave rise to Syriac, which in turn developed into a number of Old Iranian scripts such as Sogdian, which by 700 CE had provided the basis for the Old Uyghur alphabet. Old Uyghur could be written RtL in lines, but also top-to-bottom in columns. When the Mongols adapted the Old Uyghur alphabet to their own language in 1204 CE they fixed it in the TtB format, though the Mongolian script came to favour arranging the columns LtR.