Many mitvot require that one stand. One of which is reading the Torah. Thus, the ba'al koreh and the person making the blessing stand. When it comes to those who are just listening, there is a debate whether they are required to stand as well. Some hold that the listeners are required to stand while others require the listeners to stand only for the blessings, and finally others don't there is a nearly universal custom to stand during the recitation of the Ten Commandments. Tracing the history of this custom, however, uncovers that not only is this a fairly recent custom, it is also a highly problematic one.
The earliest possible source for this custom, as with many of today's "universal" customs, is the Hemdat Yamim. The Hemdat Yamim, records that:
According to the Hemdat Yamim, the custom of the Ari (most of his customs the Hemdat Yamim attributes to the Ari, see this post discussing the spurious nature of the Meron custom also attributed to the Ari,) was to not stand for the recitation of the Torah with the exception of the Ten Commandments. Importantly, the Hemdat Yamim is only proposing this custom, not attempting to justify an already existing custom. Moreover, as we shall see, most who discuss the custom of standing for the ten commandments do so in an effort to reconcile this custom with the prohibition of elevating or highlighting the ten commandments as proscribed by the Talmud.
For instance, R. Shmuel Aboab discusses the custom of standing for the Ten Commandments. R. Aboab was asked "about the custom of some to stand for the Ten Commandments, what is the reason for this custom and should others follow it?" In his response, R. Aboab first questions the custom in light of the well-known passage in the Berachot where the Talmud records that the custom to read the Ten Commandments was abolished in the "gevulot" due to the "minim." Thus, according to the Talmud, highlighting the Ten Commandments or, in this case, standing specifically for their reading may run afoul of this passage. Ultimately, R. Aboab defends the custom of standing and distinguishes the Talmudic passage and claims that the Talmudic restriction is only applicable "when it is unclear why one is favoring the Ten Commandments over the rest of the Torah, i.e. when one reads the Ten Commandments daily. But, here, [merely standing on Shavout or Parshat Yitro or Vethanan] the purpose is clear in that we are reenacting the acceptance of the Divine Glory and thus there is no fear of the minim. The standing for the Ten Commandments is thus akin to standing when we recite the blessing on the new moon, . . . as Abbai states we need to do it standing and Rashi explains that since we are greeting the Divine Glory we are required to make the blessing standing out of respect for the Divine Glory. Therefore, we stand when the Ten Commandments are read and it poses no problem."
The Hida also defends the custom of standing and argues the Talmudic fear of minim is not applicable as the Ten Commandments are read as part of a larger Torah reading thereby demonstrating that although we may stand for part we believe in it all.
In fact, it is not an exaggeration to say, from the early 18th century there has been a virtual explosion of commentaries attempting to justify this custom in light of the Talmud. 
Of course, as with most Jewish customs, not everyone agrees that standing for the Ten Commandments is appropriate. R. Y. Emden (additions to the Siddur, Laws of Shavout) holds that one should not stand for the Ten Commandments as does R. Gieger in Divrei Keholot (p. 466).
Returning now to the origins, the earliest and most likely source is the Hemdat Yamim, which dates to sometime in the 17th century. That said, he is not actually the earliest person to discuss this custom. Rather, the Rambam discusses this custom, however, the Rambam cannot be the source for the custom of standing for two reasons. First, this passage of the Rambam was unknown until the 20th century. Second, the Rambam was against the custom of standing for the Ten Commandments.
The Rambam's statement appears in two editions of his responsa, first in the Freimann edition and then again, with small differences, in the Blau edition. The first, Freimann was published in 1934, and Blau's was published in 1971. Consequently, these can not be the sources for the custom discussed in the 17th century as these were still in manuscript and unknown in the 17th century - that is, no one mentions the Rambam until the publication of these editions. Moreover, as we have seen, this is not a inconsequential custom, rather, on its face this custom runs counter to the Talmud and thus if in fact this custom pre-dated the Hemdat Yamim why is there no one who raises the conflict with the Talmud in Berchot. As we have seen, once the custom is discussed it is almost always in the context of justifying the custom in light of the Talmudic passage.
The Rambam, contrary to the position of those discussed above, takes issue with standing during the Ten Commandments. Specifically, unlike those above, he is unwilling to distinguish the Talmudic passage and in fact expands on what the Talmud prohibits. According to the Rambam, based on the Talmud, it is prohibited from elevating any part of the Torah over any other part. As the Rambam discusses at length in his Commentary on the Mishna, the introduction to Perek Helek, it is heresy to claim any one part of the Torah is more important than any other. Similarly, the Rambam holds that to stand for one part of the Torah and not another part is akin to heresy as it shows that the Ten Commandments are somehow worthy of standing to the exclusion of the rest of the Torah.
To recap, the custom of standing seems to have become popular with the Hemdat Yamim in the early 18th century and the Rambam was against this practice ruling that it skirted the line of heresy. R. Ovadiah Yosef, basing himself on the Rambam (R. Yosef doesn't trace the lack of historical basis for the custom), rules that it is prohibited to stand. Surprisingly, this is not the conclusion reached by all his contemporaries. Instead, R. Waldenberg, takes the position that since this is well-established "minhag yisrael" standing for the ten commandments is permitted. R. Waldenberg raises the possibility that this custom falls in the category of those customs which are so powerful they override law.
R. Waldenberg then deals with the Rambam, and essentially dismisses the Rambam as unimportant because this responsum was unknown. R. Waldenberg then throws in for good measure the controversial statement of the Hazon Ish regarding using recently discovered manuscripts. 
R. Waldenberg is not the only one to dismiss this responsum. R. Feinstein also discusses standing for the Ten commandments and offers his own justification. In doing so he never mentions the Rambam's position. R. David Feinstein was asked if his father was aware of this responsum and R. D. Feinstein said that his father was not. But, R. Dovid continued, "knowing his father's position on newly discovered manuscripts - [that he took a dim view?]- the Rambam's responsum doesn't affect the analysis."Feldman, Yisrael be-Mamadam, p . 1051.
Thus, rather then dealing with the Rambam in a meaningful manner many appear to be willing to dismiss the entire position of the Rambam. Furthermore, the reason for this pithy dismissal is not based on substance but, instead, by alleging without any basis in fact that this responsum is a forgery.
In sum, the custom of standing is based on the Hemdat Yamim and is not older than the 18th century. The Rambam had serious reservations about establishing such a custom, but some are willing to ignore the Rambam on questionable grounds.
See Y. Goldhaver, Minhagei Kehilot, vol. 1 227-36 where the majority of the above is taken from. See also, Sperber, Minhagei Yisrael, vol. 2, 109-11, n.63 (he discusses among other things, the meaning of "minim"); E. Brodt, Yeruschasanu, vol. 2, p. 208; G. Oberlander, Minhag Avotanu be-Yadanu, Nissan-Av, chapter 27; S.Y. Feldman, Yisrael be-Mamadam, vol. 2, 1040-51.
See also, Goitein, A Mediterranean Society, vol. II, 340 where he records the custom that to take an oath one had to swear "in the name of God, and the Ten Commandments." And that a document from Syracuse, Sicily, it records that "the party giving the oath was even obliged to read the Ten Commandments aloud from the Torah Scroll."
 R. Aboab's distinction is far from certain. Specifically, why it is clear on Shavout one is standing for a particular purpose as opposed to the daily recitation of the Ten Commandments?
 This reasoning is also not convincing as the proposed daily recitation of the ten commandments was also in a larger context where other Torah passages are recited, Shema, Az Yashir, and Tehilim. If reading the ten commandments during Yitro obviates the minim issue why doesn't reading it with the Shema or the Monday and Thursday Torah readings obviate the minim issue?
 See R. Ovadiah Yosef, Yeheva Da'at, vol. 1 no. 29 where in his typical fashion cites almost all the relevant literature.
 R. Waldenberg is not the first, nor presumably will he be the last, to question the authenticity of a particular responsum of the Rambam. For other examples, see Y.S. Speigel, Amudim be-Tolodot Sefer ha-Ivri, Kiteva ve-Hatakah, 264-65.