Carpal tunnel syndrome is caused by compression of the median nerve, which can be due to various reasons, including repetitive wrist movements, tendon inflammation, fractures, or medical conditions such as diabetes and rheumatoid arthritis.