You can visit Iran by car but I don't think you will get permission for Iraq. 1st of all, there are many documentary formalities to drive your car in another country.
You need a Carnet de Passage and international driving license.
Secondly, road entry to Iraq is brohibited nowadays due to covid.19. They are only issuing group visas.
Anyways, it's better to visit your nearest Iranian consulate. You will get complete information for both countries from there.
It will be tough to drive such a long journey. But if it's possible, then nothing like it. Roads are very good through out Iran. And also in Iraq. You will enjoy the drive. Only Quetta to Taftan border is tough drive.
On the other hand, you can visit Iran, Iraq by public transport or by air and hire vehicles there for visiting these places. Usually they offer packages for ziaraat around these cities and know exactly where to take you. And they can't overcharge you because it's thier everyday's routine and there are a number of options available.
Secondly, long route busses and trains are very comfortable and luxury there, specially in Iran. And driving own car for many days will be tiresome.