Because it would have been an act of aggression to close off the strait. Iran did not want to invite war, the US and Israel have entirely been the aggressors in this recent conflict.

Sanctions were also an act of aggression. Iran could ask for fees for US ships to make up for their losses due to sanctions.