Why is lye used in some recipes for cookies?
First of all, lye is not "water boiled with ash".  You might be thinking of potash, which used to be used as lye, but virtually all food-grade lye today is sodium hydroxide.

In terms of its function, it largely raises the alkalinity (pH).  Baking soda does too, but sodium hydroxide is far more potent - let's just say you don't want to get any on your hands by accident.

The reason some recipes use lye is that alkalinity is a major promoter of the Maillard reaction, which is responsible for the crisping and browning you see in many baked goods - most notably pretzels.  I haven't seen cookie recipes using it but I imagine that those recipes would produce very crisp and hard cookies - not my cup of tea but maybe that's what you want.

The only ingredient I know of that you can use instead is baking soda, but I wouldn't call that a replacement, more like a substitution.  It will work the same way, but in the end you'll have something much softer and less browned.

There is actually another substance that is in between the pH of sodium bicarbonate (baking soda) and sodium hydroxide (lye), and that is sodium carbonate AKA "washing soda".  It's listed as a food additive (E500) but it is rather difficult to find in food-grade forms.  As its name implies, it's more commonly used as a detergent.  However, it would be a better substitute than baking soda due to its higher pH.

One can make food grade sodium carbonate (Na2CO3) from food grade baking soda, sodium bicarbonate (NaHCO3), by baking it an oven spread out on a cookie sheet at 350° F for one hour; baking longer won't hurt.  This drives off water and carbon dioxide to form food grade washing soda (sodium carbonate) which increases the pH more than baking soda.

Here's the reaction for the above process:


  2NaHCO3 ---> Na2CO3 + CO2 + H2O