How do they know which chain is the real one? Basically how are chains kept in sync so that there is only one main chain?
The "real" chain is whichever chain a majority consensus of network participants considers to be real.  There isn't exactly a "real" chain; only an "agreed upon" chain.

Bitcoin is an incentive based system, and in the long term, it is in everyone's best interest to use the chain that everyone else is using.  Bitcoin clients use a "longest chain" rule to determine which fork of the chain is the one they (individually) consider to be "real".  Of course, every block on this chain must abide by the rules which that client deems to be the "real" rules.  When different clients disagree on what these rules are, a hard fork occurs.