A federal judge said Wednesday horseshoe crabs cannot be commercially harvested from a national wildlife refuge in South Carolina to benefit a pharmaceutical company, ruling in favor of an environmental group that argued the federal government improperly authorized the activity.