As heard from R’ Yakov Minkus
 
ז. זְכֹר יְמוֹת עוֹלָם בִּינוּ שְׁנוֹת דּוֹר וָדוֹר שְׁאַל אָבִיךָ וְיַגֵּדְךָ זְקֵנֶיךָ וְיֹאמְרוּ לָךְ
7. Remember the days of old; reflect upon the years of [other] generations. Ask your father, and he will tell you; your elders, and they will inform you.
  
טז. יַקְנִאֻהוּ בְּזָרִים בְּתוֹעֵבֹת יַכְעִיסֻהוּ
16. They provoked His zeal with alien worship; they made Him angry with abominations deeds.

Ha’azinu is a repetition of history and everything that happened in the Torah so far for example:
 
The first letters in the first 4 psukim are:
ה = הַאֲזִינוּ
י =  יַעֲרֹף 
כ = כִּי
ה = הַצּוּר 
 
These four letter equal a gematria of 40, corresponding to the letter מ.  The 5th pasuk starts with a  שֶׁ and the sixth starts with a ‘ה’.     
מ + ש + ה = משה 
 
The Midrash Tanchuma says that an author usually writes his name at the end of his book. If we apply this here then Ha’azinu seems to be the end of the Torah, even though on first glance it seems that the parsha of V’Zos Habracha is the final parsha. However, if we look into it then we will see that in fact, V’Zos Habracha is not a halachic or historical parsha, it is ’merely’ Moshe’s farewell speech to the Jewish People and his Brachos to them.

In last week’s parsha, Nitzavim-Vayelech, it says, ‘כִּתְבוּ…הַשִּׁירָה הַזֹּאת’.

In this weeks parsha it says, ‘הַאֲזִינוּ הַשָּׁמַיִם…וְתִשְׁמַע הָאָרֶץ’ Finally, in the beginning of the Torah, parshas Bereishis it says, ‘ א. בְּרֵאשִׁית בָּרָא אֱ־לֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ: The Sefer Yetzira says that the end of an era, or in this case, the Torah, reflects the beginning.

There is an argument as to whether the instruction of ‘כִּתְבוּ…הַשִּׁירָה הַזֹּאת’ is on Ha’azinu, or the whole torah. However, if we bring in the fact that the end should reflect the beginning, it is not a question, or an argument because they are inextricably linked and, essentially, one and the same.

There is a ‘יסוד’ – a ‘secret insight’ about the importance of Heaven and Earth, of שמים וארץ. In their essence, they interact through גשם – rain and the water cycle reflects this interaction, as we will now explain:

 
ג. כִּי שֵׁם יְ־הֹוָ־ה אֶקְרָא הָבוּ גֹדֶל לֵאלֹהֵינוּ
3. When I call out the name of the Lord, ascribe greatness to our God. (Devarim 32:3)
The Rambam explains, ‘כִּי שֵׁםה’ is in שמים and ’הָבוּ גֹדֶל’ is on the ארץ. Effectively, this means that we have בכירה - a free will to see the physical in this world, elevate it in our own way and aquire the ability to be spiritual. Creating our own spirituality through the pre-existing physicality of the world.
Rain, in its being, improves, fixes, nourishes and revitalises everything it ’touches’  and this is the ’שפע’ – ‘goodness’ from שמים that provides production in the world.

We, in our own way, can connect to שמים through two different mediums - תורה and תפילה.

Why do we daven for rain? For the obvious reason that we are not looking for the physical aspect – but for the recognition of Hashem’s hand and part in our day to day physical lives.
Through תפילה, we connect to שמים and bring it down to ארץ, and through תורה we elevate the world and bring it up to שמים
Rain has two states of being. One of them being the vapor state, where moisture evaporates and ‘rises’ into the sky, and it condenses and ‘descends’ to earth.

Ha’azinu is the summary of the purpose of creation - history has proven that when we acheive this function of linking שמים וארץ, life unfolds pleasantly, and when there hasn’t been a link, there has been devastation and destruction.

 
אז הוחל: (לשון חולין) לקרא את שמות האדם ואת שמות העצבים בשמו של הקב”ה לעשותן עבודה זרה ולקרותן אלהות:
Then it became common: הוּחַל, is an expression of חוּלִין – profaneness: to name people and idols with the name of the Holy One, blessed be He, to make them idols and to call them deities. (Bereishis 4:26)
During the time of the דור ענוש there was a lot of עבודה זרה. Shamayim was ‘stopped’ and as a result the seas swelled and consumed a third of the earth – thus proving that when we sin through שמים/ תפילה we get punished through the ארץ. 
 
On the other hand, during the דור המבול the Jews sinned through the land and therefore, suffered punishment through the שמים – it rained for 40 days and 40 nights. Thus proving that when we sin through ארץ  we get punished through שמים.
 
The Zohar says that the דור המבול should have received the תורה.    
 
120 years of שת’s life was taken in order for נח to be able to wait 120 years.  Then there was the 40 days of rain which was נגד הר סיני, and when הר סיני happened, people thought there would be another מבול.

‘Vatishaches ha’aretz’ - The תורה was there to be able to elevate the physical.

Hashem broke up the world into nations, and the Jews were the link בין שמים וארץ.
In the מדבר, and when we had the ananei hakavod with us, we were with hashem, and truly experienced שמים on the ארץ on our level. When we got to ארץ ישראל, we experienced an ארץ elevated closer to שמים.
If or when we lose ארץ ישראל, we lose the connection between שמים וארץ, and the other nations will have the power to overtake and dominate us.
 
To conclude, the pasuk says, ‘הַשִּׁירָה הַזֹּאת’  and we asked, ’is it ספר תורה or תפילה?’, the answer is that it is both. When we sing it as a prayer, its שמים בארץ. When we learn it, its ארץ לשמים.