The primary purpose of boot.py (at least on the pyboard) is to initialize the USB port.
When boot.py is run, the USB port is not yet initialized, so you can call pyb.usb_mode and determine how it will be initialized.
Once boot.py exits, then the USB port is initialized and then main.py is run.