A bath before bed both relaxes your muscles and releases muscular tension. The process has a chemical effect on the body as well. Children have been doing this for many years.
While relaxing in the tub, your core body temperature rises, and then it quickly drops once you get out. The decrease in body temperature signals the brain to release melatonin. The bubbles in the bath insulate the top of the water and keep the water hot for a longer bath.