The Shia - Sunni religious differences are exploited for political reasons. Since Iran used religion to rally support from the Iranian people in 1979 to overthrow the Shah, their dictatorial ruler, the rulers of surrounding countries, especially Saudi Arabia, have been worried that this popular religious influence could spread to other countries and cause a threat to their power.
In Afghanistan both Shia and Sunni united to drive out the Soviets in the 70s and 80s but they looked to Iran and Pakistan respectively for training and arms so were influenced by extremist organisations in both countries. Shias have gained more political influence in Afghanistan since the Taliban were driven out, with some Sunni politicians choosing Shia running mates - the current and former vice presidents are Shia.
Both Pakistan and Iran have an interest in trying to maintain their influence in Afghanistan by promoting sectarian conflict. If there is no enemy waiting to kill you, there is less and less reason for groups in Afghanistan to buy arms from or rely on help (with strings attached) from Iran or Pakistan.