They are merchant marines and CIA.
But I would ask that same question: What are they doing in the Persian Gulf unaccompanied? To the external eye, most of these USNS ships resemble military ships (especially the pre-positioning ones) but this one, not so much:
Nice looking research vessel, but she screams "Spy Ship". And the Iranians, while generally a-holes (at least those in power) aren't stupid-they have ship recognition stuff too, and likely knew this was an unarmed (or lightly armed) USNS ship.
OTOH, for all they knew, there could be a security detachment on board with some shoulder fired AT-4s or something like that, which could make short work of them if they suddenly appeared on deck.
So they were likely just being dickheads, something they are good at. I agree, though...in this climate, we shouldn't leave it up to the Iranians to decide. That is what we did with the USS Pueblo. We just assumed they wouldn't attack her.
I still harbor a grudge against the Korcoms about the USS Pueblo, but we did put her in a dangerous situation. I see this could be the same thing if they snatched the ship.
Except for one thing...LBJ isn't in charge.