Why are Google and Facebook banned in China?

China has been on the Internet intermittently since May 1989 and on a permanent basis since 20 April 1994. In 2008 China became the largest population on the Internet. As of 2016, approximately 50 percent of China's population had internet connectivity

Xi Jinping Said, "the development of the Internet has posed new challenges to national sovereignty, security and development interests."

Facebook and google are foreign companies. China prefers local companies over foreign firms and often puts restrictions on foreign firms to protect the homegrown talent.  China wants its domestic firms to develop and not get shouted out by multi-billion dollar Giants from abroad.

China likes to control the message and censor the media, some foreign companies play ball (Yahoo! and Microsoft) while others refuse (Google, Twitter, Wikipedia[1]). Google used to comply with Chinese censorship, 

In 2004, Google began to consider entering the Chinese market. At that time, China's search engine only had Baidu and YAHOO. At that time, China's Internet has its own problems, Google wants to give Chinese users a better experience, so decided to set up Google China.
From 2006 to 2009, Google China's traffic and revenue are growing steadily. But they also have to block some of the content should not be shielded, the content is legal.

In December 2009, Google was attacked, these attacks from china. The purpose is to steal Google's source code and some Gmail data, including human rights activists and political dissidents.

In January 10, 2010, Google held an emergency meeting, the meeting finally allowed to gradually reduce the keyword shielding in China. This behavior will make Google China achievement cast to waste.

Google had to communicate with the Chinese government, but the two sides did not reach a consensus.

In October 2013, Google gradually shut down the server on the mainland, turned to Hongkong.

Google still does business in China. They have offices in Beijing and they sell advertising to Chinese firms. Likewise Facebook's CEO, Mark Zuckerberg is no stranger to China, he has even learned the Chinese language to an acceptably high level. He has discussed/made major deals with Chinese internet firms.

There are two ways to enter a foreign market. You can take your own brand into the country and try to eek out a bit of the market share over many years, or you can just buy into one of the existing players in that country and get instant market share. Even when Google was in China, it didn't have the real success that has had elsewhere. Yahoo has been in China for a very long time but has always struggled to capture the market even back when Yahoo was bigger than Google (remember then). Facebook also was never really popular in China. Facebook may have more success in the Chinese market by taking a stake in Chinese social media firms in just the same way that Yahoo has a huge stake in Alibaba.

Wikipedia? but that isn't blocked is it. Well, it is partly blocked. The Chinese version of Wikipedia is blocked and sensitive pages on the English site are blocked. Before 2008, Wikipedia was completely blocked.

If Google is banned inside China, which OS are the Chinese using for their phones?
They use a streamlined version of Android with Google services(like Google Play Store) not installed.

How did China manage without Facebook, Google and other banned companies?
China has its indigenous version of google- called the Baidu . Just like google its not just a search engine but also provide other services like Baidu maps, image search, video search, baidu games and a host of other features.

It is the 5th most popular website of the world and a really competitive one, because you see just like android of google it has released its own mobile OS Baidu Yi. So the Chinese are fine without google and similarly Facebook can be substituted by Renren another indigenous social networking site.

Sources: Quora, Wikipedia, google china and Google