In the beginning when things were simple, every USB device was built either as a "master" or a "slave" device, depending on what it did. For eaxmple a desktop computer would be a "master", but a memory stick or a USB printer would be a "slave".
A network of USB devices only works properly if there is exactly one "master" device.
That simple "master/slave" idea doesn't work with devices like tablets, which might sometimes need to function as a master and sometimes as a slave.
The OTG cable fixes the problem by by making one end of the cable look like the master device and the other end like a slave, independent of what devices the cable is plugged into. In other words, you can connect "anything to anything" and it "just works."