We provide necessary conditions on the regularity of domains for the optimal embeddings of first order (and higher order) Orlicz–Sobolev spaces into Orlicz spaces in the sense of [5], [6] (and [9]). We show that if A(t)≤C0tp near infinity for some p≥1 and W1,A(Ω)↪LAn(Ω), then there exists a constant C such that for every x∈Ω‾ and 0<r≤1, |B(x,r)∩Ω|≥g−1(r/C)−1, where g(s)=∫s∞An−1(t)A−1(t)dtt. In particular, if IA<n, then Ω satisfies the measure density condition. Similarly, the embedding into the space of continuous functions implies a lower bound estimate which, in the case iA>n, reduces to the measure density condition. A related condition that implies the measure density condition also in the critical case, is given by means of Orlicz–Poincaré inequalities.We also establish the optimal embeddings in an Ahlfors regular metric measure space and prove that lower bound of the measure is a necessary condition for such embeddings. More generally, we derive a lower bound for the measure of B(x,r)∩Ω under the assumption that M1,A(Ω)↪LAˆ(Ω), where Aˆ is a Young function that increases more rapidly than A near infinity. Using our results concerning embeddings combined with a generalization of a result of Heinonen and Koskela, we show that Orlicz-Sobolev extension domains satisfy the measure density condition. In the case of Hajłasz-Orlicz-Sobolev spaces, it follows that the measure density condition, or the validity of certain Orlicz-Poincaré inequalities, characterizes extension domains. We also extend the results of Korobenko-Maldonado-Rios [27] and Korobenko [26] by showing that the doubling condition on the measure is a necessary condition for some Orlicz-Poincaré inequalities.