U.S. intelligence believes that North Korea and Iran are cooperating on ballistic missile development. Both have tested two stage rockets with a range of about 2,000 kilometers. Iran appears to be ahead in the ability to make large, solid fuel, rocket motors. The cooperation between the two countries appears to be largely a matter of business, and necessity. Both nations are international outcasts, feared by their neighbors and under international trade sanctions.
So what's a pariah to do? Seek out other pariahs and do some business. Iran has oil money, and North Korea doesn't have much. This can be seen by the two million North Koreans who starved to death in the 1990s, and the persistent famine conditions since then. So while Iran can buy North Korean technology, the North Koreans can't buy Iranian stuff. Moreover, the technology for producing solid fuel rockets also requires access to some specialized industrial equipment. That also costs lots of money, and North Korea doesn't have the extensive (and well funded) technology smuggling operation Iran has created over the last two decades.
North Korea developed solid fuel rocket tech (a notoriously tricky procedure) first, and sold it to Iran (who then scaled it up for large ballistic missiles). North Korea has been developing advanced weapons longer than Iran, and still has some items the Iranians would like to buy. This includes nuclear weapons and some chemical and biological weapons technology. North Korea is so broke, that anything they have left, and Iran is willing to pay for, is available.