The caffeine in coffee and strong tea makes restless legs more likely, so try cutting them out to see if the problem improves. Similarly, try to decide whether alcohol might be a factor in your case. Dealing with stress is easier said than done - try your public library for books or tapes on relaxation techniques. It sometimes happens just when I'm trying to get off to sleep. I need to have a good kick around, which doesn't make me very popular in bed.
Some people find that cooling their legs helps to prevent attacks or relieve the sensation.
Make sure your bedroom is cool and airy. Try putting your feet in cold water for 5 minutes before going to bed, and don't use a hot water bottle or electric blanket in the winter. It is worth discussing restless legs with your doctor, because it might be a good idea to have a blood test to check your iron stores. If these are low, an iron supplement might help. Your doctor can also decide whether you have ordinary restless legs or some other condition such as rheumatoid arthritis.