In Parashat Balak, the King of Moav, Balak, becomes frightened of the Jewish people “Ki Rav Hu,” “because they have become numerous” (BeMidbar 22:3). As a result, he sends emissaries to ask Bilam, a prophet, to curse Bnei Yisrael. Consequently, Bilam requests that Hashem curse the Jews. Bilam explains, “Ulai Uchal LeHilachem Bo VeGeirashtiv,” “Maybe [because you will curse them] I will able to wage war against it [the Jewish nation] and drive them away” (BeMidbar 22:11). Hashem responds in the negative, explaining that Bnei Yisrael cannot be cursed. Upon receiving this response through Bilam, Balak, hoping to elicit a different response, continues to send more important officers to Bilam, who continuously responds that he cannot curse the Jewish people. Suddenly and seemingly arbitrarily, Hashem grants Bilam permission to go with Balak's officers to curse Bnei Yisrael. Hashem states, “Im LiKro Lecha Ba’u HaAnashim Kum Lech Itam VeAch Et HaDavar Asher Adaber Alecha Oto TaAseh” “If the men came to summon you, arise and go with them, but only the thing that I shall speak to you - that you shall do” (BeMidbar 22:20). Hashem's permission is ambiguous; he does not define specifically what Bilam will do if he goes with Balak's officers. Moreover, it does not make sense that God would suddenly change his mind; before, Hashem forbids Bilam to go with Balak's officers; now, He grants the evil prophet permission to do so.
Ibn Ezra cites an example from Devarim. After Hashem tells Bnei Yisrael “Aleih Reish,” “Go up and possess” (Devarim 1:21) the land of Israel, Bnei Yisrael propose “Nishlechah Anashim Lefaneinu” “Let us send men [the twelve spies] before us” (Devarim 1:22), entirely contradicting Hashem's original words. However, when Moshe asks Hashem to send spies, God allows the nation to “send men”. God seemingly concedes to Bilam's wishes in a similar matter, allowing Bilam to go against Hashem's original words. God also adds that Bilam must do only what Hashem tells him to do (“VeAch Et HaDavar Asher Adabeir Alecha Oto Taaseh”). Additionally, both Bilam and the 12 spies fail in their actions; as the 12 spies frighten Bnei Yisrael and cause them to wander in the desert for 40 years, Balak ends up blessing Bnei Yisrael. The failure of these two endeavors teaches that one should not doubt what Hashem commands, and that though He may tolerate our contradictory activities, it is not a sign that we are doing the right thing.