The permission of 666 for foo is masked against 002 to remove the world write bit. If the system assigns you to your own group, a common umask is 002, but if all normal users are in the same group, a good umask is 022. If you are very paranoid, the appropriate umask would be 077. Umasks can be set by the program, in the example above the shell. The initial umask is inherited from the parent process.
World write permission is usually wrong.
But don't go around removing world write permission from everything. World read permission, it depends on how secretive you are. But things like Web pages must be world readable. Sharing with a small number of people is a job for groups. But this needs sysadmin setup.