Try putting a bar of soap under your sheet right where your legs are. I am serious this works. My mother-in-law does it. She suffered from leg cramps and pains for years now she has none while sleeping.
I suppose you should find out what the cause of the leg pain "is" before you can find a solution, but if it is the common cramps that some people suffer, then it may be a potassium deficiency. Try eating a banana about an hour or so before bedtime. Some people suffer from "Restless leg syndrome" in which you would need to check with your doctor for help. Two ibuprofen before bed may help as well.