Iran fell for the same trap as Armenia & India did. They felt they were "too good" for Russia or China and wanted to integrate into the West. They had plenty of opportunities to buy decent anti-air systems as well as modern jets. They even considered the J-10C but refused it. It was all about Western integration.
I feel bad for the civilians getting caught in the middle, but this was an entirely preventable crisis. Obviously Iran has the moral high ground but geopolitics isn't about morality. Also, the regime is pretty odious even if the Zionists are worse.