Music came first historically: the oracle-bone graph showed silk strings stretched on a wooden frame — a stringed instrument. The 'happy' meaning is a borrowed extension (you feel joy when music plays), and over time the two readings split. In classical thought
礼乐 ('rites and music') were paired pillars of Confucian social order: ritual ordered conduct, music ordered emotion.