>Scarlatti, while serving as a court musician in Spain, had a serious gambling habit. This often left him in significant debt, despite his undoubtedly high income. His patron, Queen Maria Barbara of Spain, was a devoted student of his and had a deep admiration for his work, particularly his keyboard sonatas.
>To help him out of his financial troubles, the queen would reportedly pay off his gambling debts in exchange for written copies of the sonatas he had composed and performed for her. This arrangement, a "strange trade" as some historians call it, is believed to be the reason we have so many of Scarlatti's sonatas today, which otherwise might have been lost to time.