Sleeping better after drinking coffee may be due to your body's tolerance to caffeine, which can diminish its stimulative effects over time. Plus, some people might experience a paradoxical reaction to caffeine, which, rather than causing alertness, helps them relax and unwind, especially if it's part of a comforting nightly routine.