I'm a beginner web developer and I can clone facebook in a few hours.
In its core, the app is just users who can friend each other.
Add AJAX to that... and tada, something that resembles facebook.
Scaling the app to be very reactive, available to millions accessing it at the same time, and with near 100% up time is where the hundreds millions of dollars go. (and all that data mining)