The hardware serial port of an Arduino board is a quick & easy way to communicate with a serial device, like a GPS or Bluetooth module. By connecting the device to pins 0 & 1 you can receive data and send data using the IDE monitor…so long as the sketch running on the Arduino board is not using that port. If it is your device is blocked from using it.
The usual way around this is to upload a sketch that does not use the port, such as BareMinimum or Blink from Examples, which will leave the port free. But you don’t have to do this.
A more convenient way is to press and hold the reset button on the board. This kills the sketch and your data will flow freely to the monitor. Release the button and the sketch restarts. Simples.
Even better, a jumper wire from the RESET pin to GND will achieve the same result.
As far as I can tell it is the presence of the “Serial.begin()” statement that blocks access to the port. So commenting that statement out will also work.