I think Obama is relying on "the enemy of my enemy is my friend" meme.
That is why Netanyahu made such a point of correcting that meme to say that sometimes the enemy of my enemy is also MY enemy.
Here's the reason Obama supports Iran.
The Sunni and Shia both agree that Israel must be destroyed.
Obama obviously believes that Iran is better suited to accomplish that feat than any other muslim country (and indeed it is).
Ergo, he (temporarily) supports Iran.