Siddham reached Japan as part of a deliberate import. Kukai, the monk later known by the posthumous title Kobo Daishi, travelled to Tang China with an official embassy in 804 and studied at the capital under the master Huiguo, from whom he received the esoteric transmission. He returned in 806 with texts, ritual implements, a lineage and the script, and the school he founded, Shingon, has written Sanskrit in Siddham ever since. Saicho, his contemporary and the founder of Tendai, brought back a parallel esoteric transmission, which is why the same letters serve both schools.
The script travelled because the words did not. Mantras and dharani were not translated into Chinese or Japanese but transcribed, on the reasoning that what they do depends on the sound rather than on the sense, so a tradition that took them seriously had to be able to write and read the sounds. Chinese characters could approximate them and did, in enormous quantity, but an approximation cannot be reversed reliably: several Sanskrit sounds fall together in it, and a reader working back from the characters cannot tell which was meant. The Siddham letter records the sound exactly, and so it came as equipment rather than as ornament.
What followed is the reason this alphabet can be described at all. Siddham fell out of use in India, displaced by the scripts that grew out of the same Gupta stock, while in Japan it went on being copied, taught, carved and printed without a break. A script the country of its birth stopped writing survived because a school on another set of islands could not do without it.