Describes a person, thing, or atmosphere that is tastefully elegant and refined, often with a classical or courtly nuance. Can be used for appearance, behavior, or artistic style.
優雅 also means elegant/graceful but is more common and less specifically tied to classical Japanese refinement. 雅やか has a stronger traditional, courtly nuance.
上品 means refined/elegant in a general sense of good taste and politeness, without the classical aesthetic nuance of 雅やか.
Etymology
Derived from 雅 (みやび, 'courtly refinement') with the adjectival suffix やか, forming a na-adjective. The exact historical derivation is uncertain, but the word is associated with Heian-era aesthetics.