Google has reached a $500 million settlement with the government, the Justice Department announced on Wednesday. The search company has been charged with illegally displaying ads for online pharmacies that fail to require prescriptions and sell counterfeit drugs. The investigation began in May, after which Google set aside a large sum for the potential settlement. In the past, Google has admitted that regulating ads from illegal pharmacies on its site is difficult, because the companies find loopholes in each new rule. The $500 million fund Google set aside has decreased its quarterly profits by 22 percent.