Every now and then, weather can take out a server or an entire datacenter. Recently, an Amazon datacenter lost power due to severe storms in Virginia, which forced several major websites offline including Netflix, Pinterest and Instagram
Probably the most common reason for a site going down is that someone, or a team of people wrote bad code. The bad code could take down one page, or several websites depending on what code has errors. There are sometimes millions of lines of code that go into serving a single webpage on your browser window, so there are plenty opportunities for programmers to make errors.
Difference in web browsers can make it difficult for developers. A page could display perfectly in one web browser (ie Firefox), but the same feature or page in another browser (ie. Internet Explorer) could be broken. Making webpage features work smoothly on all browsers is usually the goal of web developers, but sometimes things slip through the cracks.
Most websites run off of one or more computers, and these computers are typically powered by and stored in data centers. These storage facilities need several Internet service providers in order to stay connected, protection from natural disasters and fires, robust air-conditioning systems and backup power supplies. When these fail, the websites hosted on the servers in the data center fail too.
The same way your home computer can get a little slow or crash, web servers can become overloaded and shut down or slow down so terribly loading pages can take too long. The resources available to the website may not be able to keep up with demand from people visiting the site. Typically memory, cpu and database queries can be over utilized pretty quickly if a website is not optimized or ready for high traffic spikes.
Hackers take down sites for many different reasons, and have many ways that they hack a site. A hacked site can sometimes host malicious code, so whenever you see a notification that a site may be harmful, it is best to just click the back button and plan on visiting that site another time once the site has fixed the issue.
Hackers use DoS (denial-of-service) and DDos (distributed denial-of-service) attacks to try and overload a server or network temporarily. If successful the websites hosted on the server become very slow, or completely overloaded and go offline. DDos attackers send commands to multiple computers (usually compromised with viruses) called botnets, that then attack the same website or server all at the same time. There are many methods used by hackers to flood systems.
Every now and then computers or computer parts break which can cause websites to be inaccessible. Every website relies on one or more computers to send you each and every page you visit. If the computer parts don't work correctly, you aren't going to see the webpage correctly, or at all.
Down for maintenance
Typically, websites are ever-evolving and have new code that needs to be published. When you see an under construction or maintenance message, this usually means that the operators need some time setting up and testing the new code on the server. It could be as simple as one file that needs one line of code changed, to entire systems being switched with security upgrades and shiny new servers.
Simply put, things connected to the Internet (like computers and servers) have numbers assigned to them as addresses. Names are used to alias those numbers (like google.com) so it is easier for humans to remember them. Sometimes the numbers change, which can make locating the server or service difficult. Imagine your home address changes and you have to let other people and businesses know about it. Sometimes a few poor souls get the wrong address, or they don't get updated at all. Now you have a bunch of mail that can't find you. The same thing goes for a website or server; if your computer hasn't been correctly told of the new address, it won't be able to find the website.
The above reasons do not cover every single possible outage issue, including any user related problems. Some outages are out of the control of website owners, and typically involve political, government or Internet service provider blockages.