There are several functions of setting in this play. Most simply, because it is set "somewhere else" (other than England), as a dramatist Shakespeare can use wild local customs. Since it is Asia Minor, he can use the customs of the exotic East, raising the stakes in the drama by the threat of a death penalty.
Since it is part of the Greek world, he can evoke lots of the historical/mythic references and use such names.
Since it is a port, he can expect lots of walk on characters (including unknown people) and lots of action (and the shipwreck); since it is at war he can make the stakes higher.
Shakespeare's selection of Ephesus for the setting of the play (the action of the play takes place in a single day in a single place) has been noted by critics as an important alteration in the play, since Ephesus was associated with sorcery, exorcism, mystery cults, and emerging Christianity.