Great question. Today most vehicles are programmed to lock the doors when placed in gear or when driven above about five miles per hour. By locking the doors, the door latch is separated from the door handle. In an event of a crash this would prevent the doors from opening.
Here is what happens and why the doors are locked: