When Adam (as) disobeyed Allah (swt) by eating of the forbidden tree, he was punish there and then by being sent on Earth to be tested, and the rest of mankind to be tested. However, when Iblis disobeyed Allah, he was not punish then, but he will be punished in the future when he will be put in Jahanum. Why didn't Allah punish him then? Why did Allah give him the chance to try and make mankind go astray? I mean I would have expected Allah to punish him immediately especially when he challenged Allah to make people go against Allah.
(Iblis) said: “Allow me respite till the Day they are raised up (the Day of Resurrection).”)
قَالَ إِنَّكَ مِنَ المُنظَرِينَ
(15. (Allah) said: “You are of those respited.”)
Surah 7 Al-Araf, verse 13-15
Now the reason as to "Why" Allah (SWT) chose to "Allow this Dua from Iblis" Is because "He's Allah (SWT)" and as "HE/Allah (SWT) says.
And if God had so willed, they who succeeded those [apostles] would not have contended with one another after all evidence of the truth had come to them; but [as it was,] they did take to divergent views, and some of them attained to faith, while some of them came to deny the truth. Yet if God had so willed, they would not have contended with one another: but God does whatever He wills.  - 2:253
Zachariah] exclaimed: "O my Sustainer! How can I have a son when old age has already overtaken me, and my wife is barren?" Answered [the angel]: "Thus it is: God does what He wills." - 3:40 (Asad)
[Thus,] God grants firmness unto those who have attained to faith through the word that is unshakably true  in the life of this world as well as in the life to come; but the wrongdoers He lets go astray:  for God does whatever He wills. - 14:27
I mean If "Allah (SWT)" chose to "Punish Iblis, right there and than" HE/Allah (SWT) would have "Punished him (Iblis) right there and than" but "HE/Allah (SWT) always knew of Iblis's, truthful nature", and "HE/Allah (SWT)" also knew "That Adam (A.S) was always gonna end up on Earth (One way or another), and It was "Willed by Allah (SWT)" that Adam (A.S)+Hawa (R.A) would end up on Earth and be the "Founders of the human civilization" and that our "Greatest enemy would be Iblis and his followers".
It's not that "Allah (SWT) Is giving Iblis the chance to lead (Us/Mankind to go astray)" It's that "Mankind (Some of them) take the devils as protectors/friends/confidant, and thus "Choose to go with Iblis rather than follow the path that Allah (SWT) wants for HIS Creation". As such, this Is the path that "They/Certain humans have chosen", and as such (For choosing said path), they will have It's reward In the end, and that Is as "Allah (SWT) states".
“Surely, your Lord is Allah Who created the heavens and the earth in six Days and then rose over (Istawâ) the Throne (really in a manner that suits His Majesty), disposing the affair of all things. No intercessor (can plead with Him) except after His Leave. That is Allah, your Lord; so worship Him (Alone). Then, will you not remember? 4. To Him is the return of all of you. The Promise of Allah is true. It is He Who begins the creation and then will repeat it, that He may reward with justice those who believed and did deeds of righteousness. But those who disbelieved will have a drink of boiling fluids and painful torment because they used to disbelieve”
[Yunus 10:3, 4].
Some He hath guided: Others have (by their choice) deserved the loss of their way; in that they took the evil ones, in preference to Allah, for their friends and protectors, and think that they receive guidance.
Now to answer the (Final point) as to "Why Allah (SWT), didn't Just punish Iblis, right there and than, after (Having his/Iblis's Dua granted) for stating that "he/Iblis was gonna make mankind go astray", It's "Because Allah (SWT) granted Iblis Dua" and as such "Allah (SWT) doesn't break HIS word after allowing a thing to be" In this case (After granting the supplication of Iblis). That was when Iblis got mouthy and stated his true Intent (Having nothing to lose) and no way back (In his mind).
(Iblees (Satan)) said: “O my Lord! Give me then respite till the Day they (the dead) will be resurrected.” Allah said: “Then, verily, you are of those reprieved, “Till the Day of the time appointed” (Quran, Surah al-Hijr: 36 – 38).
Than (After knowing Allah) granted his/Iblis's Dua, does Iblis state.
(Iblees (Satan)) said: “O my Lord! Because you misled me, I shall indeed adorn the path of error for them (mankind) on the earth, and I shall mislead them all. “Except Your chosen, (guided) slaves among them” (Quran, Surah al-Hijr: 39 – 40).
because Iblise did a lot of ebada until he gets a highest rank of a jinn can be achieved Allah has shown justice to him even iblis disobeyed Allah want iblis to witness that the Rightous human how they retreat iblis and how Allah was right in the creation of human Iblis will be crying and cursing himself when he see the pure and pious people
This is what my understanding Allah knows best.