Why did Shlomo Hamelech think that the secret of the red heifer should be revealed to him?
(19,17) “And they shall take for the ritually impure person from the ashes of the burnt purification cow, and put upon it spring water in a vessel.”
The gemora in Rosh Hashanah 21b says that Koheles (Shlomo Hamelech) wanted to be like Moshe, but a voice from heaven said: “It is written straight words of truth” (Koheles 12:10).
This teaching is very enigmatic, but we can explain it according to the teaching of the Yalkut Shimoni that Hashem said to Moshe: To you I am revealing the reasons of the red heifer, but to others it is a statute. Thus we see that the reasons of the red heifer were revealed to Moshe, but Shlomo Hamelech said “I thought I was wise, but it is distant from me” (Koheles 7:23).
And I saw in a certain sefer that there is an allusion from the initial letters of some of the words of our posuk that the reasons of the red heifer were revealed to Moshe:
לטמא מעפר שרפת החטאת
But these letters could also allude to Shlomo Hamelech, since they also spell שלמה. However, there is a difference between the two possible allusions - the allusion to Moshe is made by reading the letters in the order in which they are written, but the allusion to Shlomo is made by changing their order.
This is the meaning of the gemora in Rosh Hashanah - Shlomo wanted to be like Moshe and have the reasons of the red heifer revealed also to him, because he thought that just as the letters allude to Moshe, so too they allude to him. Therefore a voice from heaven told him “It is written straight words of truth”, that the letters which allude to Moshe (למשה) are written straight, but this is not so for the letters שלמה.