Allah azza wa jal said – translation of the meaning-:
(And let not those who [greedily] withhold what Allah has given them of His bounty ever think that it is better for them. Rather, it is worse for them. Their necks will be encircled by what they withheld on the Day of Resurrection. And to Allah belongs the heritage of the heavens and the earth. And Allah, with what you do, is [fully] Acquainted. ) H\K\saheeh translation (3:180)
A note before quoting the tafsir of the ayah:
“Inheriting” that happens between humans is of things that they don’t “own”, it is things that belonged to someone else, and then after the”owners” death they “inherited” it.
but for Allah azza wa jal, everything is His (He owns it), and it belongs to Him, he is al Malik, everything is Allah’s “mulk”.
so for humans they are taking something that was not there’s at first, then they owned it after “inheriting” it, while Allah azza wa jal is taking something that is His, that belongs to Him, so it was His before and after “inheriting”.
Imam at Tabari rahimahu Allah said in his tafsir of ayah (3:180):
تفسير الطبري – (ج 7 / ص 440)
القول في تأويل قوله : { وَلِلَّهِ مِيرَاثُ السَّمَاوَاتِ وَالأرْضِ وَاللَّهُ بِمَا تَعْمَلُونَ خَبِيرٌ (180) }
قال أبو جعفر: يعني بذلك جل ثناؤه: أنه الحي الذي لا يموت، والباقي بعد فَناء جميع خلقه.
فإن قال قائل: فما معنى قوله:”له ميراث السموات والأرض”، و”الميراث” المعروف، هو ما انتقل من ملك مالك إلى وارثه بموته، ولله الدنيا قبل فناء خلقه وبعده؟
قيل: إن معنى ذلك ما وصفنا، من وصفه نفسه بالبقاء، وإعلام خلقه أنه كتِب عليهم الفناء. وذلك أنّ ملك المالك إنما يصير ميراثًا بعد وفاته، فإنما قال جل ثناؤه:”ولله ميراث السموات والأرض”، إعلامًا بذلك منه عبادَه أن أملاك جميع
خلقه منتقلة عنهم بموتهم، وأنه لا أحد إلا وهو فانٍ سواه، فإنه الذي إذا أهلك جميع خلقه فزالت أملاكهم عنهم، لم يبق أحدٌ يكون له ما كانوا يملكونه غيره.
وإنما معنى الآية:”لا تحسبن الذي يبخلون بما آتاهم الله من فضله هو خيرًا لهم بل هو شر لهم سيطوقون ما بخلوا به يوم القيامة”، بعد ما يهلكون وتزولُ عنهم أملاكهم، في الحين الذي لا يملكون شيئًا، وصار لله ميراثه وميراث غيره من خلقه.
Rough translation:
(The tafsir of His saying : “and to God belongs the inheritance of the heavens and earth; and God is aware of the things you do”
Abu Ja’far (at Tabari) said: Allah -jal thana’uhu- meant by that: that He is the alive that does not die, and He remains after the perishing of all of His creation.
and if one says: so what does His saying mean: “and to Him belongs the inheritance of the heavens and the earth” and “the inheritance“, that is known, is the transfering of the property\ownership from the owner to the inheriter, after his death, and to Allah is the dunya (this world) before the perishing of the creation and after it ?
It is said (to him): the meaning of that is what we described, His (Allah’s) describing of Himself with eternal existance, and His informing of His creation that He has decreed their perishing.
And because the property of the owner becomes inheritance after his death, so Allah azza wa jal said: “to Allah is the inheritance of the heavens and the earth” informing, by that, that the property of all of His creation is transfering to Allah (going back to Him) after their deaths, and that no one but will perish except Him (Allah), for He is the one when perishing all of His creation, and all of their property is removed from them, no one will remain for their property to go to except Him.
and the meaning of the ayah: “And let not those who [greedily] withhold what Allah has given them of His bounty ever think that it is better for them. Rather, it is worse for them. Their necks will be encircled by what they withheld on the Day of Resurrection” (3:180), after they perish (the niggard\greedy) and their property is removed from them, in the time that they don’t own anything, to Allah becomes its intheritance, and the inheritance of rest of His creation.