Transference for the Erd\H{o}s-Ko-Rado theorem