Throughout this answer, keep in mind that the stacking order (from the top) is Escape Tower (ET), Command Module (CM), Service Module (SM), Lunar Module Shroud, Lunar Module (LM). See here for the full Saturn V diagram or here for a simplified diagram.
The CM and SM do need to be connected - the capsule is only good for a few hours comfortable operation without the SM's support systems, and NASA's safety culture precluded any in-flight connections being made that were not mission essential. (A failure to dock to the LM would not be a mission failure, per se. It would abort the landing, but the LM was essentially just pushed along with the CM/SM)
The shroud serves several purposes - one of which is transferring the load of the ET/CM/SM stack down to the S-IVB. The shroud also prevents damage to the LM before and during launch, and keeps the LM separated from the SM, as well as streamlining the stack, and preventing animals being accidentally carried. Note that the LM is not actually connected to the SM while inside the shroud - the CM/SM stack separates from the shroud, which then itself opens, revealing the LM.
The LM itself is a dual stage design - the Lunar Descent Module, and the Lunar Ascent Module.
#Alternate Stacking
NASA did consider some alternate stacking schemes, but these were not for the Apollo CM/SM/LM as launched - these final designs were concept approved well before production designs were completed. Two of the three other stackings considered (see link 1) are worth discussion.
One alternate stack was a CM/SM/LunarLaunch/LunarLanding stack - no on-orbit docking maneuvers. It would have, however, required a larger launcher than the Saturn V, and would have had the potential for losing all three astronauts at once at the moon, and would not have had the orbiting CM for comm relay and visual confirmation. The costs of designing an even larger launcher were considered prohibitive.
The CM design could not have had the LM above it - it would have made the escape tower too massive, and the Apollo project was run almost to the safety limit already. Further, that would have put several tons of highly explosive fuel above the CM at load, which would have been rejected even by the (now relatively lax) safety standards of 1960's NASA.
The LM cannot be used as the TLI/LOI engine, either - it would require more structural mass, and the LM engine is left of the surface.