The only president to serve more than two terms was Franklin D. Roosevelt. In 1940 he won the election for his third term. Four years later in 1944, he ran again and became the only president to be elected to a fourth term. However, he was just a few months into his fourth term when he suffered a cerebral hemorrhage and passed away on April 12, 1945.
Roosevelt was able to remain president for so long because the country was in a state of turmoil - World War II and the post-depression era - and he was a popular and reliable figure the people felt could lead them during their weakened times. Hope this helps!!