"Behold, God has granted you all those who sail with you." Behold, if it were not for Paul, all who were in the ship would have had to perish. Thus, what was said by Homer is false: Homer says that it is impossible to escape the mortal fate that determines the hour of a person's death together with their birth. But consider: if all were destined to perish, then, by ordinary reckoning, Paul too should have perished, having spent so many days at sea without food! Yes, the false mind said: "Neither the brave man (that is, the valiant) nor the coward escapes fate"… Something entirely different is ...said in Scripture, namely: "The righteous is delivered out of trouble, and the wicked comes in his stead" (Prov. 11:8). Thus, God granted the souls to Paul, but the ship with everything on it perished. In this way, the ungodly are saved this time for the sake of the righteous. It also happens that the ungodly person perishes prematurely because of his own ungodliness, as Ecclesiastes says: "Do not give yourself over to sin, and do not be foolish: why should you die before your time?" (7:18).
Source: Commentary on Acts