He had a civil case like 10 years ago which was sealed in a deal that he admitted to some stuff in exchange for immunity of some sort. That was prior to the statute of limitations expiring. This year the DA decided to dump the immunity deal and since he said this under oath prior to the statute expiring, he argues the statute no longer applies and he charged Cosby.
Cosby is clearly a scumbag. But note that the authorities all knew this info and is only going after him now because of the publicity.