The phrase "the empire on which the sun never sets" has been used with variations to describe certain global empires that were so extensive that there was always at least one part of their territory that was in daylight.
It was originally used for the Spanish Empire, mainly in the 16th and 17th centuries. In more recent times, it was used for the British Empire, mainly in the 19th and early 20th centuries. During this period, the British Empire reached a territorial size larger than that of any other empire in history.
Georg Büchmann traces the idea to a speech in Herodotus' Histories, made by Xerxes I before invading Greece.
A similar concept in the Old Testament might pre-date Herodotus and Xerxes I where Psalm 72:8 speaks of the Messianic King: ‘He shall have dominion also from sea to sea, and from the river unto the ends of the earth’ for ‘as long as the sun and moon endure, throughout all generations’ Ps 72:5. This concept had existed in the Ancient Near East before the Old Testament. The Story of Sinuhe (19th century BC) announces that the Egyptian King rules “all what the sun encircles.” Mesopotamian texts contemporary to Sargon of Akkad (c. 2334 – 2279 BC) proclaim that this king ruled “all the lands from sunrise to sunset.”
In the early 16th century, the phrase, "el imperio en el que nunca se pone el sol" (the empire on which the sun never sets) originated with a remark made by Fray Francisco de Ugalde to Charles I of Spain (r. 1512 to 1556), who as king of Spain and as Holy Roman Emperor Charles V, had an empire, which included many territories in Europe, islands in the Mediterranean and Atlantic, cities in North Africa and vast territories in the Americas.