Well, a few thoughts here...
The government of Sudan repeatedly tried to turn Osama over to the US but Clinton refused to take him. This led to Osama leaving for Afghanistan.
In Afghanistan Clinton launched a cruise missile strike greatly PO'ing the Taliban, and doing little else. After that point the Taliban refused to consider discussing a turn over. They were therefore a reliable base for Osama.
Moving to Iraq would move Osama into being an easier target for another attack seeing as we have bases in Turkey, Kuwait, and Saudi Arabia that we had used to attack Iraq in the past.
So, while the living standard would be higher, Osama was much safer in Afghanistan, and as we all know, they still allowed his minions to raise money for AQ in Saudi Arabia, so proximity was not an issue.