The question is raised why the Parsha of Amalek directly precedes the Parsha of Ki Tavo? The Bal Haturim answers the question. Amalek's obsessive and nefarious goal was to prevent Bnei Yisrael from entering the Land of Israel. Amalek tries to stop Bnei Yisrael achieving their ultimate destiny at every turn. It is a spiritual battle fought in physical terms.
G-d Almighty assures the Children of Israel in Parshat Ki Tavo that they will overcome Amalek, "And it shall be when thou has come into the Land of Israel which Hashem your G-d has given you as an inheritance and you shall possess it and dwell in it". No one including Amalek will stop you. The Land of Israel is an eternal inheritance to the Jewish People.
It could not be stated any more clearly than in Parshat Ki Tavo. According to the Bal Haturim Amalek waged war three times before Matan Torah (the Giving of the Torah at Sinai). They not only tried to prevent the Children of Israel from entering the Land of Israel they tried to prevent Bnei Yisrael from receiving the Torah and entering into an eternal covenant with G-d at Sinai. The first time was in relation to Lavan, the father-in-law to Yaacov. Lavan and Amalek are connected by the Bal Haturim.
It is not a mere coincidence that the prayer recited at the time of bringing the first fruits to Jerusalem which we relate to Lavan "An Aramean destroyed my Father and he went down to Egypt and sojourned there few in number and he became there a Great Nation mighty and populous" occurs in Parshat Ki Tavo when defeat of Amalek is guaranteed. The very fact that Jews live in Israel today is a victory over Amalek. This is the significance of the first fruits. They testify to the fact that Amalek/Lavan was and will be defeated. What better way of bearing witness to the defeat of Amalek than Bnei Yisrael entering the Land of Israel and bringing the produce of the Land to our Holy City of Jerusalem. It ties the Parshiot ( of Amalek, Ki Tavo, and First Fruits) together well.
The second time Amalek struck according to the Bal Haturim was when they told Pharoah that the Jews were leaving Egypt for good and that they were not going on a three day "road trip".Amalek goaded Pharoah into attacking Bnei Yisrael and led to the destruction of the Egyptian Army at the splitting of Yam Suf. Amalek and Pharoah together were defeated.
The third time Amalek struck was before Matan Torah and Yehoshua waged war against them. "So Joshua did what Moses had commanded and fought the army of Amalek" Exodus 17:10. With each defeat of Amalek the Jews grew stronger. Whether the Nazis were Amalek ,and I believe they were in the last generation, or Iran is Amalek today, and I believe they are, is not the point. The Jews have had many enemies over the millenia. Our enemies all wanted to destroy every last one of us.
G-d Almighty runs the world. Our enemies do not understand this concept.They were all, and always will be defeated. We are still standing they are not. G-d proves this over and over again. One day the world will come to that understanding and stop attacking us. I hope it comes sooner rather than later. Shabbat Shalom