  In mathematical modelling, the data and solutions are represented as
measurable functions and their quality is oftentimes captured by the membership
to a certain function space. One of the core questions for an analysis of a
model is the mutual relationship between the data and solution quality. The
optimality of the obtained results deserves a special focus. It requires a
careful choice of families of function spaces balancing between their
expressivity, i.e. the ability to capture fine properties of the model, and
their accessibility, i.e. its technical difficulty for practical use. This
paper presents a unified and general approach to optimality problems in Orlicz
spaces. Orlicz spaces are parametrized by a single convex function and neatly
balance the expressivity and accessibility. We prove a general principle that
yields an easily verifiable necessary and sufficient condition for the
existence or the non-existence of an optimal Orlicz space in various tasks. We
demonstrate its use in specific problems, including the continuity of Sobolev
embeddings and boundedness of integral operators such as the Hardy--Littlewood
maximal operator and the Laplace transform.
