https://mechanics.stackexchange.com/a/25370/12697 Covers the physical arrangment of gears in a basic differential. The key to understanding a differential is to understand how these gears behave under different scenarios.
The gearing arrangement means that relative to the crown wheel the two half shafts are constrained to turn by equal and opposite ammounts.
Looking from outside the differential this means that the average speed of the two half shafts must be equal to the speed at which the crown wheel turns. So when the engine turns the propshaft at least one of the wheels must turn.
We also see that if the differential is frictionless then the torque delivered to the two wheels must be the same since any difference in torque would cause the gears inside the differential to change speed.
If both the drive wheels have good grip then the basic differential works great at transferring power to the road while allowing the drive wheels to turn at different speeds.
The same principle can be extended to more wheels, for example a 4 wheel drive vehicle will usually have three differentials, one in the center for differences between front and back and then front and back differentials for differences in speed between left and right of each end.
If one wheel loses grip then the wheel that loses grip will spin freely since the torque delivered to the wheels is the same very little power will be delivered to the wheel(s) that still has grip.
So in performance cars systems are built to detect undesirablly high levels of slip and limit them either through the cars brakes or through extra mechnisms in the differntial. There are also more complex types of differential that have different torque VS speed characteristics.
Losing traction on your 4 wheel drive vehicle when one wheel slips kind of defeats the object of having 4 wheel drive. Old fasioned off-roaders often used crude mechnisms to lock up the differentials when driving off road. More modern off roaders often have fancier systems similar to those on performance cars.