Jared Owen writes:
Simple toys like this are actually quite complex on the inside! I had a lot of fun taking apart cars to try and figure out how this works. It's complicated to explain things like this - feedback is always welcome.
I wrote a python script to create the mesh, armature, and a single property that drives the rotation on the bones in the armature. I'm not sure if there's a better way to do this but it worked for me. The gears were animated manually - it was complex enough that the physics engine couldn't handle it so well.
Render time was around 60 hours. I hope you enjoy!
(I created and rendered this video in blender 2.79b - I'm not brave enough yet to try the 2.80 beta!)