On the origin of the intracluster light in massive galaxy clusters