We can see in the answers to Why would "breakfast" be translated as "lunch"? that, up until at least the end of s. XIX, almuerzo and desayuno were proper synonyms.
Nowadays, however, to most people they mean different meals (the most common distinction is, I think, that desayuno is had first thing in the morning, i.e. a breakfast, and almuerzo is kind of a second breakfast, closer to midday).
When did this distinction appear?
And why did we set on "desayuno" being the earlier one?