It states (9:18-23) ישראל בני יסעו 'ה פי על, Bnei Yisrael traveled by Hashem's command. When the הכבוד ענני (clouds of glory) gave the signal, they traveled.
את ישראל בני ושמרו רבים ימים המשכן על הענן ובהאריך יסעו ולא 'ה משמרת, "When the cloud lingered over the Mishkan for many days, Bnei Yisrael kept the charge of Hashem and did not travel. 'ה פי על המשכן על מספר ימים הענן יהיה אשר ויש יסעו 'ה פי ועל יחנו, "Sometimes, the cloud remained for several days above the Mishkan; at Hashem's bidding they encamped and at Hashem's bidding they traveled.
ונסעו בבקר הענן ונעלה בקר עד מערב הענן יהיה אשר ויש ונסעו הענן ונעלה ולילה יומם או, "Sometimes the cloud remained from evening until morning, and when the cloud departed in the morning, they traveled. Or, the cloud remained for a day and a night, and when the cloud departed, they traveled.
לשכן המשכן על הענן בהאריך ימים או חדש או ימים או יסעו ובהעלתו יסעו ולא ישראל בני יחנו עליו, "Whether it was for two days, a month or a year, that the cloud lingered to hover over the Mishkan, Bnei Yisrael would encamp and not travel, and when it departed, they traveled. יסעו 'ה פי ועל יחנו 'ה פי על, "At Hashem's bidding they would encamp, and at Hashem's bidding they would travel..."
What was the reason that at some places, they stayed for months and even years, and at other places, they were there for a week or a month, and there were times that they were at a location for just a night or a day?
Reb Yitzchak of Volozhin zt'l (son of Reb Chaim of Volozhin zt'l) explains that the Jewish nation traveled to forty-two locations in the desert (as they are counted in parashas Masai), and each location represented another yetzer hara that the nation had to conquer. When they conquered this yetzer hara, they could travel to the following location.
For example, perhaps one location was the origin for the yetzer hara for anger, another location roused the yetzer hara for laziness, and so on.
The Leshem zt'l (Leshem Shvo Va'achlamah vol.2, drush 4:20:4) elaborates, "It was extremely hard for the Jewish nation when they came to those places in the desert because they immediately felt the yetzer hara's cloak of darkness and they fell from their madreigos, drastically. They wanted to flee from those places like someone escaping from fire.
"After they were at the location for some time and they succeeded in purifying the region from the yetzer hara, they wanted to remain there [because the yetzer hara wasn't disturbing them anymore]. The Torah writes, יסעו 'ה פי ועל יחנו 'ה פי על, ‘They camped, and they traveled by Hashem’s decree.’ They didn’t do what they wanted to do; they followed Hashem's will...'
The Leshem writes, "The Torah says, הענן ובהאריך, 'When the cloud was at a location for a long time...' They had to remain in that place for a long time because the tumah of that location was very strong, and they needed more time to purify that place from the yetzer hara. At those places, it was extremely hard for the Jewish nation [because they had to deal with a very strong yetzer hara]. They wanted to run away, nevertheless, יסעו ולא 'ה משמרת ישראל בני ושמרו, 'Bnei Yisrael kept Hashem's decree, and they didn’t travel.'
"There were places that the cloud stayed only בקר עד מערב, 'from nighttime until morning' and the reason is because those places weren't so impure. They wanted to stay there longer. Nevertheless, when the cloud left Ohel Moed in the morning, they traveled on."
