How were the Magellanic clouds formed?
They are remnants of previous galaxies.
Recent studies of the Small Magellanic Cloud indicate that it might be a former single galaxy split into two remnants. Gravitational interactions with the LMC may have broken that galaxy apart.
The Large Magellanic Cloud contains a highly active starbirth region called the Tarantula Nebula. It is part of a larger cloud of gas and dust, and its high rate of star formation may be caused by compression of interstellar gas and dust by the collision of the cloud with the interstellar medium.