I just want to know because its been coming up in the news with the UK and other places a lot lately.
Wikipedia says that:
While ages from 10 to 13 were typically regarded as acceptable ages for sexual consent in Western countries during the mid-19th century,[1] by the end of the 19th century changing attitudes towards sexuality and childhood resulted in the raising of the age of consent to around 16 [4].
I don't know much about civil law countries, but in 1875 the age of consent was raised to 13 from 12 in Britain, and Wikipedia reports that "English common law had traditionally set the age of consent within the range of 10 to 12". So there was a long standing tradition that some people were too young for sex, and that this age was roughly the age of puberty. You can still see this reflected in some state laws; for example, in New Hampshire, it is still legal for a 13 year old girl and a 14 year old boy to get married (with parental permission). So, in that sense, in "true pedophile" sense of sexual activity with someone who has not yet reached puberty, it seems like pedophilia was always both taboo and illicit. However, our contemporary usage of pedophilia often extends beyond that usage and includes pubescent minors of various ages (generally younger than 16 or so), technically known as Hebephilia and Ephebophilia depending on the victim's age.
I can tell you precisely what brought about the change in age of consent from 13 to 16 in 1885 in Britain: Elizabeth Armstrong. She was a girl, only 13, who was purchased by newspaperman (incognito, for this exposé) for £5. These headlines, understandably, created a rather large moral scandal, and brought the public behind the dramatic increase to the age of consent--something social reformers had been pushing for for years. After the scandal was published, "the government passed a bill raising the age of consent to 16 before the week was out." For more context on this particular case, the BBC has a nice little summary of some of the aftermath.
This does not mean that before 1885 sexual relations between adults and adolescents was rampant (at least, no reason to assume it was more rampant than it is today, where social scientists and activist generally estimate 1/5-1/7 girls and 1/20-1/25 boys are sexually abused as minors) or that relationships between adolescents and adults were widely accepted. Age of marriage, which we can assume was typically also the age of first sexual contact, in the West has historically been late teens or early twenties, and was, at least on average, generally between people with an age gap that we'd still think was socially appropriate enough even today (there were certainly exceptions, especially among the nobility for whom marriage was often a much more strategic act).
The changing laws around sexual contact with post pubescent adolescents all fits in well with changing ideas about "childhood" as an abstract concept in the era. I've seen some truly great answers explaining the changing ideas of childhood on this sub, but I can't seem to find them now. Regardless, I'll leave that part for someone whose expertise that is to explain. You may also be interested in older answers related to child marriage/pedophilia in our FAQ, some of which deal with age of consent and some of which deal with more typical marriage ages.
Pedophilia is not illegal.