The verb and noun spoof both refer to trickery or deception, and they trace their origins back to a game called "Spoof" (or "Spouf," depending on the source you consult), supposedly created by the British comedian and actor Arthur Roberts.
There's not much information on what sort of game Spoof was. Our first written evidence of the game Spoof comes from 1884, and the citation in question tells us only that the rise of the popularity of the game must be credited to Mr. Roberts. By 1888, the name of the game had been made into a verb that referred to being tricked out of something:
Grannie, the fisherman, returns, despondently. He has lost best fly, which has been taken by a prodigious fish. "So," says he, "I was spoof'd over that. He thinks it rather hard to be "spoof'd."
—"Due North," Punch, 27 Oct. 1888
Still later citations for the noun and the verb indicate Spoof wasn't an organized tabletop game, but was rather an informal opportunity to trick or bluff another. Our best examples for this use come from a feud between Mr. Roberts and the playwright Frank Burnand. Burnand wrote a part for Roberts in one of his plays:
At last, however, the eventful evening arrived, when it was found that the popular actor ... did not know one single syllable of the part allotted to him, and was offering what would have been called at other times a deliberate insult to the public. ... [N]ot caring one brass farthing for the public in front of him, Mr. Roberts had the assurance to play a game that he is believed to have invented called "Spoof." The British public was to be spoofed by the actor. What did he care so long as he gagged, bluffed, and blundered through a part written with infinite care?
—"Scrutator," Truth, 16 Jan. 1890
By the 1900s, both the noun and verb spoof had fully developed their "hoax" and "trick" meanings. But the idea of deceiving someone with a clever joke or imitation of something eventually developed into its own meaning. By the middle of the 20th century, both the noun and the verb spoof gained meanings that referred to parody.
Today, we're more likely to run across spoof in slightly more sinister contexts than flubbed lines. Spoof is used to refer to the method of imitating another person's identity—especially an electronic identity, like an email address or a social media account, usually for personal gain or nefarious purposes. That spam link that seems to come from your friend's email address is actually a form of spoofing, as is the junk telemarketer robocall you receive three times a day from numbers all over the country. It's not that the spammers have actually gained control of your friend's email account, or have somehow hijacked actual phone numbers: it's that they've developed software that imitates or steals a real email address or phone number and uses that instead, to gain the trust of their marks.