Many viruses utilize molecular motors to package their genomes into preformed capsids. A striking feature of these motors is their ability to generate large forces to drive DNA translocation against entropic, electrostatic, and bending forces resisting DNA confinement. A model based on recently resolved structures of the bacteriophage T4 motor protein gp17 suggests that this motor generates large forces by undergoing a conformational change from an extended to a compact state. This transition is proposed to be driven by electrostatic interactions between complementarily charged residues across the interface between the N- and C-terminal domains of gp17. Here we use atomistic molecular dynamics simulations to investigate in detail the molecular interactions and residues involved in such a compaction transition of gp17. We find that although electrostatic interactions between charged residues contribute significantly to the overall free energy change of compaction, interactions mediated by the uncharged residues are equally if not more important. We identify five charged and six uncharged residues at the interface that play a dominant role in the compaction transition, and also reveal salt bridging, van der Waals, and solvent hydrogen-bonding interactions mediated by these residues in stabilizing the compact form of gp17. The formation of a salt bridge between Glu309 and Arg494 is found to be particularly crucial, consistent with experiments showing complete abrogation in packaging upon Glu309Lys mutation. The computed contributions of several other residues are also found to correlate well with single-molecule measurements of impairments in DNA translocation activity caused by site-directed mutations.