Issues with the question itself
Fundamentally, there is an intrinsic problem with asking a human being to explain the wisdoms of the Creator of human beings. However, this does not mean that it is harām to ask such questions. Rather, what is impermissible is to reject a ruling given by Allāh (subhānahu wa ta’āla) just because one does not understand it.
An important point to understand here is that the innate desire for justice and mercy within human beings is one that has come from Allāh in the first place. Therefore, deferring to Allāh our opinions on justice would be a logical necessity, because the limited sense of justice that we have is contingent on Him.
If we perceive something Allāh does as lacking mercy, we can either hold the impossibility that Allāh (subhānahu wa ta’ālā) lacks mercy, or the possibility that the lacking is within ourselves. If it is the former, then this would only make our own sense of mercy or justice questionable, as that sense was created by Allāh in the first place. Therefore, the most appropriate action would be to hold our own understanding or limited perception at fault.
The question of eternal punishment often arises when one presupposes their own understanding of justice to be above that of Allāh. In a society where liberalism and utilitarian ethics are the norm, an individual’s desires reign supreme over any higher moral code. Such questions are the consequence of a person’s assumption that their feelings on an issue have more weight than the decree of Allāh. From an Islamic perspective, we understand that, because of the complete ownership Allāh has over us, and due to His station, He can do with us as He wishes, whether we see the wisdom of that or not. Allāh says in Surah Al-Anbiyā’:
لَا يُسْأَلُ عَمَّا يَفْعَلُ وَهُمْ يُسْأَلُونَ
He is not questioned about what He does, but they will be questioned.
The assumption that one has the right to challenge the judgements of Allāh is an attitude only seen in the example of Iblīs in the Qur’ān:
وَإِذْ قُلْنَا لِلْمَلَائِكَةِ اسْجُدُوا لِآدَمَ فَسَجَدُوا إِلَّا إِبْلِيسَ قَالَ أَأَسْجُدُ لِمَنْ خَلَقْتَ طِينًا
[Mention] when We said to the angels, “Prostrate to Adam,” and they prostrated, except for Iblīs, who said, “Should I prostrate to one You created from clay?”
However, in the example of Prophet Ibrahim (‘alayhī al-Salām) and the angels, we are presented an example of the mindset we should have when asking questions about Allāh:
وَإِذْ قَالَ إِبْرَاهِيمُ رَبِّ أَرِنِي كَيْفَ تُحْيِي الْمَوْتَىٰ ۖ قَالَ أَوَلَمْ تُؤْمِن ۖ قَالَ بَلَىٰ وَلَٰكِن لِّيَطْمَئِنَّ قَلْبِي ۖ قَالَ فَخُذْ أَرْبَعَةً مِّنَ الطَّيْرِ فَصُرْهُنَّ إِلَيْكَ ثُمَّ اجْعَلْ عَلَىٰ كُلِّ جَبَلٍ مِّنْهُنَّ جُزْءًا ثُمَّ ادْعُهُنَّ يَأْتِينَكَ سَعْيًا ۚ وَاعْلَمْ أَنَّ اللَّهَ عَزِيزٌ حَكِيمٌ
[Mention] when Abraham said, “My Lord, show me how You give life to the dead.” [Allāh] said, “Have you not believed?” He said, “Yes, but [I ask] only that my heart may be satisfied.” [Allāh] said, “Take four birds and commit them to yourself. Then [after slaughtering them] put on each hill a portion of them; then call them – they will come [flying] to you in haste. And know that Allāh is Exalted in Might and Wise.”
وَإِذْ قَالَ رَبُّكَ لِلْمَلَائِكَةِ إِنِّي جَاعِلٌ فِي الْأَرْضِ خَلِيفَةً ۖ قَالُوا أَتَجْعَلُ فِيهَا مَن يُفْسِدُ فِيهَا وَيَسْفِكُ الدِّمَاءَ وَنَحْنُ نُسَبِّحُ بِحَمْدِكَ وَنُقَدِّسُ لَكَ ۖ قَالَ إِنِّي أَعْلَمُ مَا لَا تَعْلَمُونَ
[Mention, O Muhammad], when your Lord said to the angels, “Indeed, I will make upon the earth a successive authority.” They said, “Will You place upon it one who causes corruption therein and sheds blood, while we declare Your praise and sanctify You?” Allāh said, “Indeed, I know that which you do not know.”
In both these examples, a question was asked from a place of sincerity, and the answer was accepted without argument. From this, we can create a model of how we should approach asking questions about Islam.
Even if we accept the question
Even if we put aside the issues with the question itself and accept it as a valid contention, the implied premises of the question are not rationally sound. Is it more rational to judge the length of the sentence by the length of the crime, or by the severity of the crime? For example, in a court case where the crime committed is murder, would it be rational for the defendant to argue that because the crime only took three seconds to complete, the sentence length should also be three seconds? Clearly, to argue this would be fallacious.
Most people would probably agree that the punishment of a crime should be based on the severity of the crime. However, one could counter this by questioning whether the crime of shirk is severe enough to deserve eternal punishment. The dhulm of shirk is not comparable to a sin against a human being. Sins against human beings are finite in their consequence, so their punishment is also finite. However, because of the sheer arrogance of denying or associating partners with the One who created you and the cosmos you reside in, and the eternal nature of who the sin is committed against, the punishment should accordingly be eternal.
An additional point that theologians have made based on the āyah from Sūrah al-An’ām is that, had those people who committed shirk have an eternity to live, they would have committed it for an eternity.
بَلْ بَدَا لَهُم مَّا كَانُوا يُخْفُونَ مِن قَبْلُ ۖ وَلَوْ رُدُّوا لَعَادُوا لِمَا نُهُوا عَنْهُ وَإِنَّهُمْ لَكَاذِبُونَ
But what they concealed before has [now] appeared to them, and even if they were returned, they would return to that which they were forbidden; indeed, they are liars.
In conclusion, the question, if posed as a challenge, is baseless, as human beings have no right to challenge the decisions of the Creator. Furthermore, even if the question is accepted, it is irrational because of three things: punishments are never based on the duration of a crime; the sin itself is eternal in nature, and so should the punishment; and lastly, those who die upon shirk (not having repented) would have done so for eternity if they could, making an eternal punishment only fitting.
 Al-Qur’ān 21:23
 Al-Qur’ān 17:61
 Al-Qur’ān 2:260
 Al-Qur’ān 2:30
 Al-Qur’ān 6:28