I want to know where and why exactly do people use opto isolators?
I want to separate the grounds of the motors(running thru an L293D) and the muc... can i use an opto isolator for it? If yes, how exactly should i use it?
There's no need to, but yes, you can.
An optocoupler (look at a datasheet for one) is an (IR) LED shining on eg. a phototransistor to turn the transistor ON or not shining to turn the transistor OFF.
The controller should thus turn on the LED when the transistor should conduct.
The transistor is then used to control the other side.
Why you want to separate the grounds, I don't see, if say the motor is really noisy on the power lines, the ground of the power "side" will radiate that noise and may radiate into the low power ground.
It's better to deal with the noise by removing it as close to the source as possible instead.