Maharshal is among those who say that Rashi wanted to avoid inserting himself into the disagreement about whether Yisro came before Matan Torah (the giving of the Torah) or afterwards. If he had mentioned the possibility that it was the giving of the Torah that Yisro heard (and motivated him to come), since this could only have happened after that event occurred, it would obviously only be valid according to the opinion that he came after Matan Torah. However, Rashi doesn’t seem to avoid mentioning differing opinions elsewhere, and in fact does mention this dispute too (18:13). He also apparently does take sides, implying (on 18:13, giving his own opinion then adding “even according to those who say he came before Matan Torah) that he is of the opinion that Yisro came after Matan Torah, as well as praising Yisro for leaving the comforts of home in order to learn Torah (18:5). [His reference to the Torah on 18:9, which he includes as part of “all the good that G-d had done for Israel” — even though it is not included in the M’chilta (which is Rashi’s source) — could be referring to the parts of the Torah taught at Marah, not what was first given at Matan Torah, and therefore does not necessarily impact Rashi’s opinion on when Yisro arrived.]
An additional issue to contend with is that both Talmudic sources indicate that those of the opinion that it was the splitting of the sea or the war with Amalek are also of the opinion that Yisro came before Matan Torah (while according to the opinion that it was Matan Torah obviously it was afterwards). If so, by mentioning the splitting of the sea and the war with Amalek, Rashi is inserting himself into this discussion, not avoiding it! (Not to mention that it would contradict Rashi’s apparent stance about when Yisro came.) If Rashi is not trying to avoid the discussion about when Yisro came, why did he omit the opinion that Yisro came because he heard about Matan Torah?
Another question that arises is why Rashi presents these two opinions as one (that Yisro heard about both the splitting of the sea and the war with Amalek), rather than bringing them as they are quoted in the original sources, as two different, or differing, opinions.
Many commentators discuss the merits of each opinion about when Yisro came. [Ibn Ezra brings five “proofs” that it had to be after the public revelation at Mt. Sinai. Of these, the most powerful is the verse (18:5) which states that Yisro came to “the mountain of G-d,” i.e. Mt. Sinai; the nation would not yet have been there if the revelation hadn’t yet taken place (or was about to).] One of the “proofs” brought by those of the opinion that Yisro came before Matan Torah (including the Ramban) is the placement of Yisro’s coming. The Torah doesn’t tell us about the nation leaving Refidim (where the war with Amalek occurred) and arriving at Sinai (Chorev) until chapter 19, which is after Yisro leaves (18:27), indicating that the story of Yisro happened first, before they left Refidim (which is obviously also before they got to Mt. Sinai).
When Rabbi Yehoshua says (in the M’chilta and in Z’vachim) that Yisro heard about the war with Amalek, he adds, “which is written next to it.” If this was placed in chronological order, being written right after this war cannot be taken as a proof that it was the cause of Yisro coming, as the Torah is only relating things in the order in which they occurred. If, however, things were not taught in chronological order, placing Yisro’s story at this spot is a valid indicator that the two are connected. Rashi, who (as previously mentioned) seems to be of the opinion that Yisro came after Matan Torah, may therefore only quote these two opinions in order to explain why Yisro’s story is placed here if it occurred later. By telling us Yisro’s story before telling us about Matan Torah, we know that it must have been an earlier event (such as the war with Amalek or the splitting of the sea) that motivated Yisro to come.
[As far as why Yisro waited to come until after Matan Torah if the reasons he came occurred earlier, there are several possibilities. Among them is that Yisro knew the nation would eventually serve G-d on the same mountain where his son-in-law had the burning bush experience, so waited until they arrived there. Another is that there wasn’t enough time after hearing about these things to meet them any earlier, as the Torah was given only fifty days after leaving Egypt (and they arrived at Mt. Sinai a week before that), with the war against Amalek occurring between the exodus and when they reached Sinai. (This is one of the “proofs” brought by Rabbeinu Avraham ben HaRambam that Yisro must have come after Matan Torah.)]
Although this explains why Rashi chose only these two opinions, it is inconsistent with the implication in the two Talmudic sources that only according to the third opinion (that Yisro heard about Matan Torah) did he come after the revelation. Nevertheless, if we take a closer look at these sources, we are not forced to say that the other two opinions (that the splitting of the sea or the war with Amalek caused Yisro to come) must also be of the opinion that Yisro came before Matan Torah.
When the Jerusalem Talmud brings the dispute about when Yisro came, it knows who argued about it (Yehuda the son of Rebbe and Rabbi Yanai, which are, incidentally, different names than those having the same dispute in the Babylonian Talmud), but not which of them held which opinion. It therefore brings the other dispute, about what Yisro heard, where it is Yehuda the son of Rebbe who says that he heard about Matan Torah, proving that he must be the one who said that Yisro didn’t come until after it had occurred. However, it does not prove that the other two opinions regarding what Yisro heard (neither of whom is Rabbi Yanai) must be of the opinion that he came before Matan Torah.
Both the splitting of the sea and the war with Amalek were written in the Torah before Yisro came, but if the only reason he came was because of the splitting of the sea, Yisro meeting up the nation should have been written right after that, before the war with Amalek (just as it was written before they got to Sinai even though, according to Rashi, he joined them at Sinai, to indicate that he came for reasons other than the giving of the Torah). Therefore, if Rashi understands the placement of Yisro’s coming to be an indicator of why he came (and not when he came), the splitting of the sea couldn’t have been the only reason he came. It could have been part of the reason why he came, but the war with Amalek had to also be at least part of the reason, which is why Yisro coming was placed after it. And why Rashi combined both reasons, as opposed to stating them as independent opinions.