Please tell me why I have to connect one of the wires of arduino gnd to the gnd of a relay or a bluetooth module?
If you are constructing a complex circuits or connecting many boards and sensors together, you really need to provide a common ground for all the devices.
The main reason is here we are dealing voltage and different circuits operate at different voltages. It is important to understand that voltage is the potential difference between two points in the circuit. This value is relative to the circuit itself since every circuit has its own ground (GND) pin. What this means is there is no absolute potential difference for a complex circuits. Hence, it is important to establish a common ground such that all potential difference can be measured from a common GND pin.
For instance, consider you have an arduino (operates at 5V) connected to motor controllers or relays (operates at 12V) and there are no common ground established between them. This will mess up the signals from arduino to motor controllers or relays. The output signals coming from the arduino may not be 5V but lower. Therefore, it is not detected by the motor controllers/relays.
I hope this helps.
Electric circuits need to be closed. The hydraulic analogy might help you in this sense: suppose you have a garden fountain and want to recycle its water; if you want water to circulate by means of a pump, you need a way to put the water back in the pump. That's what the ground connection is for.
Sometimes you have closed circuits using other wires, and a ground connection (or a shorter, direct ground connection) might be required to keep at bay the effect of EMI (electro-magnetic interference). For example, this is the output of an Arduino Nano sensed by connecting only the tip of the oscillocope probe to pin 13.
And this is the same output when I connected the ground tip to Arduino's GND (actually to the USB frame):