The Yalkut Shimoni uses an interesting story to explain the Mitzvah to “Remember what Amalek did you”; One upon a time there was a king who planted a vineyard, placed a vicious guard dog inside a fence. He warned everyone that the dog would attack anyone who climbed the fence. The prince, the king’s own son, ignored his father’s warning and was, exactly as the king foretold, attacked by the dog.
Whenever the king observed that his son was beginning to slip, he would take him to the vineyard and say, Remember what happened when you ignored my warnings?”
So too, whenever Israel sins, God reminds them what happened when they asked, “Is God in our midst or not?” and they were attacked by Amalek.
When we read this portion we fulfill the biblical commandment to remember that the greatest danger to our spiritual development is to question whether or not God is present in our lives. (Machberes Avodas Hashem)