Primordial gas heating by dark matter and structure formation