He was educated at Irvine Grammar School in Ayrshire, then studied in the University of Glasgow, and the East India Company College near Hertford. He arrived in India with the East India Company in 1829 as a civil servant, working first in Bengal, and served in various offices, as assistant secretary to the board of revenue, Allahabad, as collector at Azamgarh and as civil and session judge at Fatehpur. In 1844, he was appointed to be the first principal of Victoria College, Benaras, that later evolved into the Sampurnanand Sanskrit University. From 1842 to 1853 he was a Session Judge in the court at Futtehpore. During this period he was awarded an honorary doctorate in civil law (DCL) by Oxford University plus a second honorary doctorate (LLD) from Edinburgh University and a third from Bonn University (PhD). 
In 1862 he endowed the chair of Sanskrit in the University of Edinburgh, and was the main agent in founding the Shaw fellowship in moral philosophy. He was a D.C.L. of Oxford, LL.D. of Edinburgh and Ph.D. of Bonn, and was one of the first to receive the distinction of Companion of the Indian Empire.
Muir died unmarried, on 7 March 1882, at 10 Merchiston Avenue, Edinburgh.
He is buried in the Grange Cemetery against the western wall of the original cemetery, adjacent to the entrance to the 20th century extension.
Muir's main work is Original Sanskrit texts on the origin and history of the people of India, their religion and institutions (1852–1870), a study of the most important source texts of Indian cultural and religious history, with English language translation. In 1858 the first volume of his Original Sanskrit Texts (2nd ed., 1868) was published; it was on the origin of caste, an inquiry intended to show that it did not exist in the Vedic age. The second volume (1st ed., 1860; 2nd, 1871) was concerned with the origin and racial affinities of the Hindus, exhibiting all the then available evidences of their connexion, their linguistic, social and political kinship, with the other branches of the Indo-European stock. The third volume (1st ed., 1861; 2nd, 1868) was on the Vedas, a full inquiry as to the ideas of their origin, authority and inspiration held both by the Vedic and later Indian writers. Volume four (1st ed., 1863; 2nd, 1873) was a comparison of the Vedic with the later representations of the principal Indian deities, an exhibition of the process by which three gods hardly known to the Vedic hymns became the deities of the former Hindu Trimurti. The fifth and final volume was published in 1870 and was on the Vedic mythology. Muir was also the author of a volume of metrical translations from the Sanskrit, an anonymous work on inspiration, several works in Sanskrit, and many essays in the Journal of the Royal Asiatic Society and elsewhere.
In 1839, Muir published Matapariksa: Sketch of the Argument for Christianity and against Hinduism, a work that, in contrast to the vitriolic missionary tracts prevalent at that time, presented Hinduism in empathetic tone and depicted Christianity and Hinduism as more or less compatible, although Christianity was clearly depicted as superior. However while sensitive to "Hindu genius" Muir advanced miracles, moral excellence, and universality as three basic arguments in favor of Christianity. The work was controversial in India and helped launch a counter-apologetic movement among Hindu scholars.
|Wikiquote has quotations related to: John Muir (indologist)|