The question is not what are Yaʾjūj and Maʾjūj, who are they?
Most interpretations understand Yaʾjūj and Maʾjūj to be the evil ones during the Hour. However, in the following verses, the subject is always the people, not Yaʾjūj and Maʾjūj.
ٱلقرءان سورة الحشر 14
لَا یُقَـٰتِلُونَكُمۡ جَمِیعًا إِلَّا فِی قُرࣰى مُّحَصَّنَةٍ أَوۡ مِن وَرَاۤءِ جُدُرِۭۚ بَأۡسُهُم بَیۡنَهُمۡ شَدِیدࣱۚ تَحۡسَبُهُمۡ جَمِیعࣰا وَقُلُوبُهُمۡ شَتَّىٰۚ ذَ ٰلِكَ بِأَنَّهُمۡ قَوۡمࣱ لَّا یَعۡقِلُونَ
• Saheeh International
They will not fight you all except within fortified cities or from behind walls. Their violence [i.e., enmity] among themselves is severe. You think they are together, but their hearts are diverse. That is because they are a people who do not reason.
Al-Ḥashr (59), ʾĀyah 14
The Qur’an does actually say to the believers to lay siege on these people, during the Hour that is.
ٱلقرءان سورة التوبة 5
فَإِذَا ٱنسَلَخَ ٱلۡأَشۡهُرُ ٱلۡحُرُمُ فَٱقۡتُلُوا۟ ٱلۡمُشۡرِكِینَ حَیۡثُ وَجَدتُّمُوهُمۡ وَخُذُوهُمۡ وَٱحۡصُرُوهُمۡ وَٱقۡعُدُوا۟ لَهُمۡ كُلَّ مَرۡصَدࣲۚ فَإِن تَابُوا۟ وَأَقَامُوا۟ ٱلصَّلَوٰةَ وَءَاتَوُا۟ ٱلزَّكَوٰةَ فَخَلُّوا۟ سَبِیلَهُمۡۚ إِنَّ ٱللَّهَ غَفُورࣱ رَّحِیمࣱ
• Saheeh International
And when the inviolable months[1] have passed, then kill the polytheists wherever you find them and capture them and besiege them and sit in wait for them at every place of ambush. But if they should repent, establish prayer, and give zakāh, let them [go] on their way. Indeed, Allāh is Forgiving and Merciful.
At-Tawbah (9), ʾĀyah 5
ٱلقرءان سورة الكهف 23
قَالَ الَّذِي عَلَيْهِمُ ارْجِعُوا فَسَتَحْفِرُونَهُ غَدًا إِنْ شَاءَ اللَّهُ تَعَالَى وَاسْتَثْنَوْا فَيَعُودُونَ إِلَيْهِ وَهُوَ كَهَيْئَتِهِوَلَا تَقُولَنَّ لِشَا۟یۡءٍ إِنِّی فَاعِلࣱ ذَ ٰلِكَ غَدًا
• Sahih International
And never say of anything, Indeed, I will do that tomorrow,
Al-Kahf (18), ʾĀyah 23
ٱلقرءان سورة الكهف 24
إِلَّاۤ أَن یَشَاۤءَ ٱللَّهُۚ وَٱذۡكُر رَّبَّكَ إِذَا نَسِیتَ وَقُلۡ عَسَىٰۤ أَن یَهۡدِیَنِ رَبِّی لِأَقۡرَبَ مِنۡ هَـٰذَا رَشَدࣰا
• Sahih International
Except [when adding], If Allāh wills. And remember your Lord when you forget [it] and say, Perhaps my Lord will guide me to what is nearer than this to right conduct.
Al-Kahf (18), ʾĀyah 24
The truth is Yaʾjūj and Maʾjūj are believers. What the following Ḥadīth says:
Gog and Magog people dig every day until, when they can almost see the rays of the sun, the one in charge of them says: “Go back and we will dig it tomorrow.” Then Allah puts it back, stronger than it was before. (This will continue) until, when their time has come, and Allah wants to send them against the people, they will dig until they can almost see the rays of the sun, then the one who is in charge of them will say: “Go back, and we will dig it tomorrow if Allah wills.’ So they will say: “If Allah wills.” Then they will come back to it and it will be as they left it. So they will dig and will come out to the people, and they will drink all the water. The people will fortify themselves against them in their fortresses. They will shoot their arrows towards the sky and they will come back with blood on them, and they will say: “We have defeated the people of earth and dominated the people of heaven.” Then Allah will send a worm in the napes of their necks and will kill them thereby.'” The Messenger of Allah (ﷺ) said: “By the One in Whose Hand is my soul, the beasts of the earth will grow fat on their flesh.” (Sunan Ibn Majah 4080)
The subject in this Ḥadīth is An-Naas till the end and NOT Yaʾjūj and Maʾjūj. And according to this same Ḥadīth, they will say InShaAllah (إِنْ شَاءَ اللَّه) which means “If Allah wills”, that would imply they are Believers.
According to ʾĀyah 59:16, these people within their fortified cities and walls are like the Shaytān – كَمَثَلِ ٱلشَّيْطَـٰن.
If Yaʾjūj and Maʾjūj won’t be the bad ones, then why did Dhal-Qarnayn build a wall between them and the people that were in grief? First, the following verses are to be read.
ٱلقرءان سورة الكهف 95-93
حَتَّىٰٓ إِذَا بَلَغَ بَيْنَ ٱلسَّدَّيْنِ وَجَدَ مِن دُونِهِمَا قَوْمًا لَّا يَكَادُونَ يَفْقَهُونَ قَوْلًا قَالُوا۟ يَـٰذَا ٱلْقَرْنَيْنِ إِنَّ يَأْجُوجَ وَمَأْجُوجَ مُفْسِدُونَ فِى ٱلْأَرْضِ فَهَلْ نَجْعَلُ لَكَ خَرْجًا عَلَىٰٓ أَن تَجْعَلَ بَيْنَنَا وَبَيْنَهُمْ سَدًّا قَالَ مَا مَكَّنِّى فِيهِ رَبِّى خَيْرٌ فَأَعِينُونِى بِقُوَّةٍ أَجْعَلْ بَيْنَكُمْ وَبَيْنَهُمْ رَدْمًا
Until, when he reached [a pass] between two mountains, he found beside them a people who could hardly understand [his] speech. They said, “O Dhal-Qarnayn, indeed Yaʾjūj and Maʾjūj are corrupters in the land. So may we assign for you an expenditure that you might make between us and them a barrier?” He said, “That in which my Lord has established me is better [than what you offer], but assist me with strength; I will make between you and them a dam.
Al Kahf (18), ʾĀyāt 93-95
So according to these verses, these people that complained to Dhal-Qarnayn had a near-unintelligible speech, they asked him to build a barrier between them and Yaʾjūj and Maʾjūj, implicitly in their likened place, because Dhal-Qarnayn says that what Allah has established for him to do is better than what they are asking him, meaning that Allah’s solution is better, the placement and type of construction decided by Allah is better, so there is a reason why these people were separated from Yaʾjūj and Maʾjūj but not as per their specifications. The reason for that is because we know that these people in these verses call Yaʾjūj and Maʾjūj “corrupters”, according to Surah Al Baqarah we are told that there are people who claim to be righteous but are actually the corrupters, that in reality they are the ones who are the corrupters despite their appearance.
ٱلقرءان سورة البقرة 13-11
وَإِذَا قِيلَ لَهُمْ لَا تُفْسِدُوا۟ فِى ٱلْأَرْضِ قَالُوٓا۟ إِنَّمَا نَحْنُ مُصْلِحُونَا أَلَآ إِنَّهُمْ هُمُ ٱلْمُفْسِدُونَ وَلَـٰكِن لَّا يَشْعُرُونَ وَإِذَا قِيلَ لَهُمْ لَا تُفْسِدُوا۟ فِى ٱلْأَرْضِ قَالُوٓا۟ إِنَّمَا نَحْنُ مُصْلِحُونَ
And when it is said to them, “Do not cause corruption on the earth,” they say, “But we are righteous.” Unquestionably, it is they who are the corrupters, but they perceive not. And when it is said to them, “Believe as the people have believed,” they say, “Should we believe as the foolish have believed?” Unquestionably, it is they who are the foolish, but they know [it] not.
Al Baqarah (2), ʾĀyāt 11-13
What’s interesting is that Fir’awn’s Council accused Mūsā and his people of spreading corruption, but they actually weren’t, every accusation of theirs was a confession, they were merely projecting their own habits on to the real righteous people.
ٱلقرءان سورة ٱلأعراف 127
وَقَالَ ٱلْمَلَأُ مِن قَوْمِ فِرْعَوْنَ أَتَذَرُ مُوسَىٰ وَقَوْمَهُۥ لِيُفْسِدُوا۟ فِى ٱلْأَرْضِ وَيَذَرَكَ وَءَالِهَتَكَ قَالَ سَنُقَتِّلُ أَبْنَآءَهُمْ وَنَسْتَحْىِۦ نِسَآءَهُمْ وَإِنَّا فَوْقَهُمْ قَـٰهِرُونَ
And the eminent among the people of Firʿawn said,” Will you leave Mūsā and his people to cause corruption in the land and abandon you and your gods?” He said, “We will kill their sons and keep their women alive; and indeed, we are subjugators over them.”
Al Aʿrāf (7), ʾĀyah 127
According to the following verse, it’s actually the disbelievers who await behind walls and in fortifications to fight people, and whilst they collectively disbelieve and therefore seem to be together, they’re actually violently divided among themselves.
ٱلقرءان سورة الحشر 14
لَا يُقَـٰتِلُونَكُمْ جَمِيعًا إِلَّا فِى قُرًى مُّحَصَّنَةٍ أَوْ مِن وَرَآءِ جُدُرٍۭ بَأْسُهُم بَيْنَهُمْ شَدِيدٌ تَحْسَبُهُمْ جَمِيعًا وَقُلُوبُهُمْ شَتَّىٰ ذَٰلِكَ بِأَنَّهُمْ قَوْمٌ لَّا يَعْقِلُونَ
They will not fight you all except within fortified cities or from behind walls. Their violence among themselves is severe. You think they are together, but their hearts are diverse. That is because they are a people who do not reason.
Al Ḥashr (59), ʾĀyah 14