Nobody knows for sure.
There are plenty of theories, and some work has been done on this interesting subject.
Here's how I see it.
Think about the types of music which make you want to dance, almost involuntarily.
They all have one thing in common - a regular and significant beat.
It's not as if the 1812 overture or 'Amazing Grace' would have everyone up on the floor.
Now picture a rave, where the dj plays an anthem with a heavy and regular rhythm. The sort of boom boom you hear as boy racers pass by.
It's an iconic image, hundreds of lithe, steamy bodies bopping in unison to the beat.
I theorise that this capacity for moving in unison to a beat is a product of hunting silently in groups.
If all the members of the hunting group have the same internal rhythm, then they can move together predictably, without the need for communication.
There is a scene in 'Saving Private Ryan' (I think) where the troops are assaulting a hill. A soldier or two runs for a few yards and digs in. Then the next soldier leap frogs his position, and so on.
It is all done in silence, but the most memorable thing was the sound and the rhythm.
If one of these soldiers did not have this sense of rhythm, the attack would have broken down.
The same sense of rhythm confers an advantage in team sports too.
'Knock ons' occur in rugby when the receiver has a different rhythm to the passer.
Armies march to a beat to train an unconscious, synchronised movement.
You could test out this theory by indulging in a straw poll.
If those folks who don't dance, or who have a poor sense of rhythm also tend not to participate in team events: it could be seen as a pointer to 'proof'. The converse, of course, would be that folks with a highly developed sense of rhythm should also be team players and more active socially.
All in all, I suspect it's why we describe ourselves as 'being in tune with someone', or not, as the case may be.