What causes light to refract? The common answer to this question is that light refracts because its speed changes in different materials. But this means that the photons has internal attraction between each other. Is that the case? Otherwise is something else like density of different materials the reason why light refracts?
please give a more convincing explanation.

 A: The reason that light travels more slowly in a dielectric is because it interacts with the electrons in that dielectric.
Light has an oscillating electric field, and if any charged particle is in the path of the light that particle will feel an oscillating force due to the oscillating electric field of the light. The result is that the wavefunction of the light becomes mixed up with the wavefunction of the charged particle.
In a dielectric the light interacts mainly with the electrons because (a) they are lighter and more mobile than the nuclei and (b) there are generally a lot more of them. So we are dealing with the interaction of the light with electrons. The result of the interaction is that the light is no longer just light. It is an entangled state of light plus electrons. This entangled state no longer has a zero mass so it travels at less than the speed of light.
The more strongly the light interacts the greater the effective mass and in cases where the interaction is very strong the light can be brought to a complete halt. This can be seen when light interacts with Bose-Einstein condensates, and indeed made the headlines a few years back when experimenters actually managed to bring light to a complete halt.
When the interaction is strong the light plus electrons forms new quasiparticles called polaritons, though for weakly interacting systems like light in glass the quaiparticle description isn't very useful.
A: This is too long for a comment, and is supplementary to the answer by John.
One should not confuse photons with classical electromagnetic light.
Photons are not light. They are elementary particles in the standard model  of particle physics, with spin + or -1 to their direction of motion zero invariant  mass and  energy=h*nu . Each photon is   described by a quantum mechanical wave function. Light emerges from the quantum mechanical superposition of innumerable photons. 

But this means that the photons has internal attraction between each other.

No, it is not attraction between photons , but superposition of photon wave functions,  which superposed functions  give a collective wave function to the emergent light wave. When entering a medium this is  modified in the way described in the answer by John,  by scatterings with the fields of the electrons in the medium.  
A: This gif shows why with Huygens–Fresnel principle:

Source
A: The reason for refraction is the different speed of light in different media. This speed is determined by the refractive index $n$, which in turn can be calculated from the relative permittivity and permeability of the material:
$$n = \sqrt{\varepsilon_r \mu_r}$$
These constants simply define the response of a material to an electric or magnetic field. Light (being made up of $E$ and $H$ fields) isn't interacting with itself, but rather with the material it is transmitted through.
So, here it is more useful to look at light in the classical picture as an electromagnetic wave, and not as photons.
A: There an many ways to look at this problem. I am going to add, light refracts because its path satisfies Fermat's Principle : "light travels between two points along the path that requires the least time, as compared to other nearby paths.”
Given the 2 different speeds of propagation in media 1 and 2:
$ v_2 \sin{\theta_1} = v_1 \sin{\theta_2} $
describes the refraction.
