Stale could once be a favourable description of ale that had settled clear. Keeping food could instead make it worse, giving the familiar freshness judgment. Ideas and jokes could then be stale through overuse.
Older senses coexisted, and the exact deeper derivation differs between sources. This trail scores the documented senses, not a particular reconstructed ancestor.
Source
Merriam-Webster: staleThe Middle English range includes settled/clear ale and not fresh; the Anglo-French and probable Dutch history is qualified.