One early instance of the expression appears in "The Easy Chair," in the [Echuca, Victoria & Moama, New South Wales] Riverine Herald (June 11, 1890):
"It is a fair cop," admitted Mr John Rose, when discovered in company with a jemmy in a house to which he had not been invited ; "but I did not mean to get into the house ; I meant the pawnshop next door." There is an engaging frankness about the explanation.
The British Newspaper Archive turns up an even earlier match—from "Alleged Breach of the Licensing Act at Darlington," in the Daily Gazette for Middlesbrough [Yorkshire] (October 4, 1881) [combined snippets; the paragraph breaks shown are conjectural and almost certainly inaccurate]:
Inspector Scott narrated the facts of the case; and evidence was given by P.C. Ferguson to the effect that on the morning of the day named, about ten minutes to ten, he saw some men loitering about the house. Suspecting something wrong, witness entered the house, and found a man with a pot of beer before him. Mrs Peacock came to the bar whilst witness was there, and when she saw him struck the pot of beer off the counter. The man remarked that there was no use telling a lie about it ; and when witness remarked that it was a fair cop Mrs Peacock appeared very much flurried.
The defence was a total denial that the liquor in the pot was beer. Mrs Peacock deposed that the man who was alleged to have been drinking beer went in her husband's house and asked her for a pint of beer. Mrs Peacock said, Not likely, and the man then asked her for a drink of water, which she gave him. In answer to Inspector Scott, witness denied that the man gave her any money. It was true that Ferguson said to her, This is a fair cop, and she replied, I don't see how you can call it a fair cop giving a man a drink of water. The defendant also swore that the pot contained nothing but water, and his statement was corroborated by another witness, who saw the water drawn.
Eventually, however, the Bench ordered an adjournment of the case, in order to secure the attendance of a witness whose evidence the police and the defence were anxious to obtain.
In each instance, the phrase "It's a fair cop" seems to mean "It is a clear case of catching [someone] in the act of doing something illegal."