Actually, In heavily doped P-N junction there are lot of donor (+ive charge) and accepters (-ive charge) in n and p region respectively. when junction is formed the electron from n side to p side to recombine with holes and vice versa, leaving behind -ive donor in n region and +ive acceptors in p region. Theses +ive and -ive charges setup an internal Electric filed Ein which prevent the further diffusion of charge carriers(electron and holes).. So in the case of heavily doped of p-n junction, only less recombination of electron and holes is required to set up the Electric field which prevent the further diffusion, resulting in narrow depletion region... while is lightly doped large no. recombination of electron and holes is required which result in wide band gap.