I was reading a philosophy article, which just talked about "the functions of..." (the subject was law, but that isn't what I'm interested in now). I am not being able to find any introductory philosophy text on "function", not even in Wikipedia (apart from entries on mathematical functions). What is a function?

You can think of a function of X as an effect E that X is designed to produce, or that X is supposed to produce, or that it is the purpose of X to produce. When is X designed to produce/supposed to produce/has the purpose of producing E? The most obvious case is where one or more conscious agents have deliberately brought about X because they desired E and believed that X would cause it. Here is another kind of case. Biological natural selection (or some similar natural process) has led to X because in the past (previous versions of) X caused E, and E is the kind of effect favoured by natural selection. (Polar bears have white fur because in the past that camouflaged them from their prey . . . etc.) Most philosophers of biology would probably say that in this case too the white fur has the function of camouflaging the bears, even though no conscious agent brought this about. Many would be equally happy to say that the white fur is designed to camouflage the bears/supposed to...

Why is it said that scientific results must be replicable? Is this also possible or should that also be the same for mathematics, history, arts or other natural or social sciences?

One difference between the sciences and other disciplines is that scientists publish experimental and observational results. Since other scientists rely on these results, they want some way of checking that they are genuine. However, this can't be done simply by scrutinizing their publication, as you might assess the value of a historical argument or piece of literary critcism. Hence the demand that the results be replicable. (This is why it is so highly charged in scientific circles to say that so-and-so's results 'are not replicable'--the suggestion is that so-and-so is incompetent or even fraudulent.)