That's a very good question.
Iran has lots of money, natural resources, a stronger economy, and scientific and trade communications with the rest of the world. And even N Korea's friendly Red neighbors knew they were crazy and wouldn't be so stupid as to help them.
The only answer I can come up with is that Iran decided it needed nukes and decided to go after them much later than N Korea, so the latter had a head start.
As for the "science" involved, that is no longer a problem. It may be advanced engineering but it's all undergraduate physics. N Korea has had their people trained all over the world, not necessarily in bombcraft, but certainly in the necessary technology.
