To compare 1-butyl-3-methylimidazolium ([BMIM])- and 1-butyl-3-methylpyridinium ([BMPy])-based ionic liquids (ILs) and investigate the influence of intramolecular and intermolecular interactions on physicochemical properties, a systematic study was performed on the electronic structures and physicochemical properties of [BMIM] tetrafluoroborate ([BMIM][BF]), [BMIM] hexafluorophosphate ([BMIM][PF]), [BMIM] hydrogen sulfate ([BMIM][HSO]), [BMIM] methylsulfate ([BMIM][MSO]), [BMIM] ethylsulfate ([BMIM][ESO]), [BMPy] tetrafluoroborate ([BMPy][BF]), [BMPy] hexafluorophosphate ([BMPy][PF]), [BMPy] hydrogen sulfate ([BMPy][HSO]), [BMPy] methylsulfate ([BMPy][MSO]), and [BMPy] ethylsulfate ([BMPy][ESO]) using density functional theory and molecular dynamics simulation. The results reveal that aggregation behavior exists in [HSO]- and [ESO]-based ILs, and the differences between their densities and self-diffusion coefficients are smaller when there is an aggregation effect in ILs. A dimer is formed by two strong hydrogen bonds between two [HSO] anions in [HSO]-based ILs, and the existence of hydrogen bonds in ILs increases density and decreases the self-diffusion coefficient. The intermolecular interaction strength of [BMIM]-based ILs is stronger than that of [BMPy]-based ILs.