Around 500 AD, the Tamil people of Southern Inda started using Grantha, a slightly different form of the Brahmi alphabet, to write Sanskrit (the language of sacred Hindu texts), while still continuing to use Vatteluttu to write representations of the Tamil spoken language. They needed to use a different script for Sanskrit because Vatteluttu, like Tamil-Brahmi, did not have characters for sounds that were not in Tamil.
As Tamil borrowed words from Sanskrit, they would preserve the origin of the spoken language in the script that they used when they wrote it. For example, if a word’s stem came from Sanskrit but the ending was Tamil, they would use Grantha to write the stem and Vatteluttu to write the ending. This was very similar to how the Japanese would use Chinese characters for the stems and Hiragana for the endings, but in the Grantha/Vatteluttu case, both writing scripts were phonetic.
Eventually, the two scripts merged, or perhaps Grantha “won”. It isn’t surprising that Grantha “won” as Vatteluttu was not ideal for Tamil even discounting loan words, as Vatteluttu was missing a way to represent terminal o, e, or u.
While Sanskrit is now usually written in Devanagari, Tamil speakers will sometimes still use Grantha, especially for ceremonial purposes like wedding invitations.