Before an illusion fooled your eyes, it laughed at you. The earliest English sense of the word was "mockery, scorning, derision."
The source is the Latin verb illudere, "to mock at." Its literal meaning was "to play with," from in-, "at, upon," and ludere, "to play." Ludere and the noun ludus, "a game, play," go back to a reconstructed root meaning "to play." From the verb, Latin made the noun illusio: "a mocking, jesting, jeering," and even "irony."
Old French had illusion by the 12th century, meaning a mocking, a deceit or a deception. English picked the word up in the mid-1300s, according to Etymonline. Merriam-Webster gives the Middle English form as illusioun, borrowed from Anglo-French and Late Latin.
The step from mocking to deceiving is a short one. To play with someone is to make a fool of them. By the late 1300s the English word also meant an act of deception, and a deceptive appearance or apparition. Etymonline says the sense of a false appearance had already developed in Church Latin.
Today the word mostly names a trick of perception, as in an optical illusion, or a comforting false belief. Merriam-Webster draws a useful line between illusion and its cousin delusion. A delusion suggests an inability to tell the real from the apparent, often from a disordered mind. An illusion is a false impression from what one sees or imagines, as in "an illusion of safety."
Delusion comes from the same play. Latin deludere meant "to play false; to mock, deceive," from de-, "down, to one's detriment," plus ludere. English had the verb delude around 1400.
Another relative is ludicrous, which arrived in the 1610s meaning "pertaining to play or sport." It took on its familiar sense of "ridiculous" only in 1782. And once you had illusions, you could lose them: Merriam-Webster dates the verb disillusion to 1855.
So whether someone is mocking you, tricking you or merely amusing you, Latin saw it all as a kind of game.