Answer
James II was the king for whom Purcell composed music. Purcell, an English Baroque composer, was a prominent figure in the musical world during the late 17th century. His works, including operas, anthems, and instrumental pieces, showcased his mastery of counterpoint and melodic invention. Purcell's association with James II, who reigned from 1685 to 1688, provided him with opportunities to create music for royal occasions and events.