Corruption of Scots the real MacKay, this latter attested in 1856 as “A drappie o’ the real MacKay” (A drop of the real MacKay).
How “MacKay” became “McCoy” is unclear; first attested with this spelling in Canada in 1881. In James S. Bond's The Rise and Fall of the "Union club": or, Boy life in Canada, a character utters, "By jingo! yes; so it will be It's the 'real McCoy,' as Jim Hicks says. Nobody but a devil can find us there."
The term is the subject of many folk etymologies, discussed at the Wikipedia entry.