The Persian Achaemenid Empire conquered huge tracts of Asia in around 500 BC, and held it until about 330 BC. They spread the use of their official language, Aramaic, and with it the Aramaic writing system. Near the end of the Achaemenid Empire, the Gandhara culture of Pakistan/Afghanistan developed a writing system that probably came from Ararmaic, but with additions to handle the different sounds of their language.
It was deciphered using bilinual Greek-Kharosthi coins. Yes, Greek. (Shortly after the development of Kharosthi, Alexander the Great swept through, bringing not only war and destruction, but also Greek colonists in his wake.)
While Kharosthi has enough clues to make scholars think it came from Aramaic, it is a very different form of writing system: an abugida. Abugidas write vowels, but the vowels are written as decorations upon the consonants as opposed to being letters in their own right. In addition, abugidas usually have a “default value” vowel which does not get diacritics. (This is different from the vowel pointing that modern Hebrew and Arabic have, in that vowel pointing is optional and Kharosthi diacritics are not.) The default vowel in Kharosthi is an “a”: glyphs for “consonant plus ‘a'” were undecorated, but otherwise the other vowel’s diacritic would be added to the glyph.
Kharosthi also has a character for an isolated vowel (which only happens at the beginning of a word). If it is an “a”, then the vowel glyph doesn’t have any decoration; if it is one of the other vowels, it gets a diacritic. Consonant clusters were shown by smooshing the characters together closely, maybe even making it a ligature. In addition, there are a few diacritics for modifying vowels (e.g. to lengthen the vowel) and a few to modify consonants (e.g. to aspirate).
How did they come up with this idea? Perhaps they came up with it themselves, but perhaps they were influenced by Old Persian cuneiform, which died out in around 300 BC. Old Persian also had “a” as a default-value vowel, but it had separate glyphs for the non-default vowels instead of them being decorations on the consonants.
Unlike other Indic scripts, but like Aramaic, Kharosthi is written from right to left.