Most modern scripts can trace their origins to Mesopotamia. A surprising number trace their roots to the writing developed in India - in fact almost every country that saw Buddhist missionary activity, excepting China, has seen some influence from the India scripts on their writing systems. That said writing came relatively late to India, and even then was not used for religious texts for many centuries.
The earliest evidence of writing anywhere in the world is from around 3500 BCE in present day Iraq. The Sumerians left caches of clay tablets at sites along the Tigris and Euphrates Rivers. This earliest writing, similar in some ways to the earliest Chinese writing (ca 1400 BCE), involves pictures which represent concepts. However it was with the invention of cuneiform that something like writing as we know began. The earliest examples of cuneiform combine signs for concepts with signs for sounds (as do Egyptian hieroglyphs). A variety of cuneiform continued to be used in the middle-east until the last century before the common era. However in the same region speakers of Semitic languages began to represent their language using only signs for sounds - i.e. to use a true alphabet - around 2000 BCE.
The Achaemenid empire (ca 550 - 350 BCE) founded in Persia adopted a form of Semitic writing, often called Aramaic after the language it encoded, for administrative purposes. It represented a significant improvement on cuneiform - it could be written (and read) more quickly and easily, and on a much greater variety of materials. Now it so happens that the Achaemenids invaded India and controlled, or at least had a powerful influence, up to the western bank of the Indus River - about half of what is now Pakistan. In fact the Buddha lived during this period and there is some evidence of Persian influence in the Pāli Canon - which I have discussed previously in this blog. The Achaemenids were toppled by Alexander of Macedonia, and in India at least the power vacuum was filled by the Mauryan Dynasty of which Asoka is the stand out figure.
Certainly by the time that King Asoka ruled India (mid 3rd century BCE) there was a well developed form of writing: the Brāhmī Lipi or Writing of God which he used on his rock pillars and edicts. Brāhmī is said to show signs of influence from Aramaic. Another script, Kharoṣṭhī, was less widely used in India proper, but was the main script in Gandhāra and parts of central Asia for some centuries. We can say with some confidence that Kharoṣṭhī was based on Aramaic as it retained many features of the Semitic script. It is possible that Kharoṣṭhī influenced the development of Brāhmī , but it is difficult to say because the earliest known examples of Brāhmī are already a fully fledged script and the direction of development subsequently is determined by the nature of Indian languages.
We can say that all forms of written language in India, as well as Tibet, Burma, Sri Lanka, Thailand, Laos and Cambodia are descendants of Asoka's Brāhmī. In India there was a very distinct north/south divide which I think was caused by writing materials, but may have been influence by the geographical spread of Indo-European languages (north) and Dravidian languages (south). The North favoured birch bark and wood to write on, while in the South the material of choice was the leaf of the talipot palm. The palm leaf is ribbed which lead to the development of the more rounded shapes of Southern writing (which then influenced Sinhala, Burmese etc). Note that technically Sinhala is a North Indian language, part of the Indo-European family, and not related to Tamil or other Dravidian languages, but it is written in a southern style script and palm leaves were the medium of choice until relatively recently. Similarly Burmese, though written with a Brāhmī derived script is part of the Tibeto-Burman family which has a relationship with the plethora of Chinese languages.
Brāhmī underwent continuous development in the North and diversified into local geographical variants. But because dynasties based in the North-east - particularly the Mauryans and then the Guptas (3rd - 6th centuries) - were dominant they tended to influence the development of writing more. The Brāhmī variant commonly used by the Guptas was by that time a distinct script. The Nalanda University was in the Gupta heartland and the Gupta script was important in the spread Buddhist texts. Later it would give rise to the Siddhamatṛkā or just Siddhaṃ script which was commonly used to write the Tantras. It is still in use today for writing mantras in China and Japan. The Gupta script, or something very like it was used as the basis for Tibetan writing, which also continued to develop independently and diversify. Siddhaṃ evolved into Devanāgarī, which is the most common script for Sanskrit in the present - though it is written using the Tamil script in South India for instance.
There are several ways of represent sounds using signs. The English alphabet attempts to convey individual sounds that combine into syllables or phonemes. This is a very efficient way of representing spoken sounds - with just 26 letters we manage to convey the 25 single consonant sounds, and 23 vowel sounds that are used in 'standard' English (as represented by the Oxford English Dictionary) and an extensive repertoire of combination of them in words and sentences. Another method is to represent speech as a series of syllables. One can either represent all possible syllables by individual signs which is only practicable if there are a small number of syllables - the Japanese Kana alphabets are good examples of this approach. An intermediate option is available where consonants and initial vowels have distinct signs and these are modified to show medial and final vowels. The latter is typical of Indian writing.
There are several distinct features shared by all Indic scripts which I will demonstrate using Devanāgarī. Initial vowels have distinct signs - 14 in Sanskrit - but medial and final vowels, and the absence of a vowel (which happens at the end of words and in conjuncts) are indicated with diacritic marks. Consonants are assumed to be followed by the short 'a' vowel unless otherwise specified. क is ka not k. Examples of vowel diacritics are: kā ke kai ki kī ko kau kṛ = का के कै कि की को कौ कृ. Vowels may also be absent, nasalised or aspirated (the technical terms being virāma, anusvāra, visarga), so g, gaṃ, and gaḥ = ग् गं गः . Indic, like English, allows for a variety of combinations of consonants without intervening vowels. These are either written as a vertical stack as in ṣ + ṭha > ṣṭha = ष् + ठ > ष्ठ; or as a horizontal combination with the initial consonant as a "ligature": t + pa > tpa = त् + प > त्प. As many as four consonants can be combined in this way e.g. strya स्त्र्य. Special variations occur with 'r' viz pra = प् + र > प्र, and rta = र् + त > र्त; ś can also undergo a special change e.g. śva = श् + व > श्व; cf śya = श्य; and some conjuncts have distinct signs jña ज्ञ and kṣa क्ष. Writing Sanskrit this way is considerably more complex than writing English.
Buddhist texts in Indic languages are preserved in a plethora of scripts: Brāhmī in many varieties, the Gupta script again in many varieties, Siddhaṃ with some variation over time (and major variants in China and Japan), Kharoṣṭḥī, Devanāgarī, several Tibetan scripts, Sinhala, Burmese, Thai etc. Each of these scripts records texts in an equally wide variety of Indian languages and dialects; and of course many texts are now known only in translation in Chinese, Tibetan or any of a dozen other languages - making the history of Buddhist texts quite complex. All this is remarkable given centuries of resistance to the use of writing for the purpose of writing sacred texts in the early days of Buddhism.
A scholar of Buddhism must often know several languages and associated scripts in order to read the relevant manuscripts. The standard of handwriting in ancient times was often quite poor, and the attention to copying of texts wavered causing scribal errors, which means that no two manuscripts are ever the same. Deciphering such manuscripts requires imagination and powers of deduction as well language skills. As such we owe a great deal to those people down the ages with the aptitude and motivation to take on the difficult task of learning these, often dead, languages and scripts, in order to study and translate the texts for us. Having dipped into their world I am in awe of them.
* The bottom line of the Brāhmī inscription pictured is a fragment of a longer stock phrase:
saḍuvīsativābhisitena me iyaṃ dhaṃma lipi likhāpita- c.f. the 1st pillar in A. L. Basham The Wonder that was India, 1967, 2001, p.395. There is now some doubt as to whether Asoka meant the Buddhadhamma or his own dhamma [see Aśoka, Pāli and some red herrings].
when I [Asoka] had been consecrated twenty-six years I ordered this inscription of the dhamma to be engraved