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):
(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.