digitalWrite() writes the pin low if the second argument is a 0 (ie, evaluates to false), otherwise it writes the pin high. This is pretty normal behavior - if you pass an integer datatype where a boolean is expected, you expect it to be false if 0, true if not zero.
What that does is loop (presumably 8 times) through that code. each pass through the loop, i has changed, so a different bit of "address" is used to determine whether the pin is written high or low. The practice of a bitwise and with a "bit mask" as is done there is a very common trick to use in embedded programming.
It's a bitbang'ed implementation of some serial protocol.
Also, << is bitwise, so 1<<2 is 0b00000100, decimal value 4. "100" would not be considered a correct way to write that.