First of all, I don't believe Iran is arming the insurgents. It's just the incompetence of the Occupying forces to secure the border that is leading to all these arms/fighters smuggling.
But, if you think about it from Iran's point of view, it is not such a bad idea to covertly arm the insurgents in Iraq. With the Americans bogged down in a fight against Iraqi insurgents and with most of their military capability tied in there, they would be more reluctant to start another war with another country. If you remember, they started the Iraq war after they handed most of the operations in Afghanistan to NATO's other member countries and thereby freed some of their troops for the Iraq war. So, the longer the insurgency goes on in Iraq, the more beneficial it is to Iran or Syria. As the Americans are now fond of saying, "it's better to fight them there than here."