It is unclear what the question is trying to stress.
If the question is asking why the Amalekites attacked the Israelites as a general matter, tradition is consulted. According to tradition, Amalek is the epitomy of hatred against the Israelites and against God. They attacked (Exodus ch.17) because the Israelites have as their duty to publicize the awareness of God. The Amalekites were a harsh and unrepentant desert tribe that saw the arrival of the Israelites as a spiritual threat and attacked.
If the question is asking why the Amalekites attacked in the desert (as opposed to a city), there was strategic benefit to doing so. The primary benefit to attacking people in transit is that they are less fortified. A secondary benefit that accrues to the Amalekites in the Sinai is that the area was familiar terrain to them, more so than to their adversaries.
The king of the Amalekites that Saul spared was Agag. Scripture records that Samuel killed Agag after Saul had failed to carry out God's command to completely destroy the Amalekites.
The Amalekites likely worshiped a variety of Canaanite deities, such as Baal and Asherah, along with other gods of the region. Their religion would have included rituals and practices common to the ancient Near East.
God commanded King Saul to completely destroy the Amalekites, including men, women, children, and animals, as punishment for their past sins against the Israelites. However, King Saul spared the Amalekite king Agag and the best of the livestock, which led to God rejecting Saul as king.
The promised land of the Israelites was Canaan, the land that God had promised to Abraham and his descendants. The Israelites returned to the promised land after being led by Moses through the Exodus, where they wandered in the desert for 40 years before finally entering Canaan under the leadership of Joshua.
Exodus 16:31 - And the house of Israel called its name Manna*. And it was like white coriander seed, and the taste of it was like wafers made with honey. [NKJV]* manna means "what is it?"
Haman, a prominent figure in the Book of Esther in the Hebrew Bible, is identified as an Agagite. This designation suggests that he was a descendant of Agag, the king of the Amalekites, an ancient people who were enemies of the Israelites. The Amalekites are often associated with hostility towards the Israelites throughout biblical narratives.
in the sinai desert
There is no information regarding the distance the Israelites traveled with Moses in the desert. It is said that they traveled for forty years.
The Moabites did not threaten to destroy the Israelites. In fact, the Moabite king, Balak, sought to curse the Israelites through the prophet Balaam but ultimately did not engage in direct conflict against them. Instead, they were more focused on preventing the Israelites from passing through their territory peacefully. Other neighboring groups, such as the Amalekites and Canaanites, posed more direct threats to the Israelites during their journey.
The Israelites were attacked along the road to Canaan by the Amalekites. This is recounted in Exodus 17:8-15 which is in the related links below.
Moses led the Israelites through the Sinai Desert.
It was the quail.
Thet wandered for 40 years in the Sinai Desert.
Moses and the Israelites
40 years
Because King Saul sinned after he attacked the Amalekites (1 Samuel 13) God rejected him and sent the prophet Samuel to appoint David son of Jesse.
The bible says they were in the desert for 40 long years.