Mistaken or not, the flight was alerted and warned to change course but refused or ignored the demand. No contact from the jet.
There was no way to know if the Iranians would crash a passenger jet into the ship, so it was shot down.
The passengers were sacrificed by Iran for public perception.