Why does starting the serial monitor restart the sketch?

The Arduino uses the RTS (Request To Send) (and I think DTR (Data Terminal Ready)) signals to auto-reset. If you get a serial terminal that allows you to change the flow control settings you can change this functionality.

The Arduino terminal doesn't give you a lot of options and that's the default. Others will allow you to configure a lot more. Setting the flow control to none will allow you to connect/disconnect from the serial without resetting your board. it's quite useful for debugging when you want to be able to just plug in the connector and see the output without having to start the sketch over.

Another way to disable the auto reset is to put a pull up resistor on the reset pin.

Disabling Auto Reset On Serial Connection


The truth is always in the datasheets, the schematics and the code:

The Arduino UNO actually uses the /DTR line to trigger a reset, as you can see on the following datasheet:

reset schematic