I searched for this question on the internet but didn't got a satisfactory explanation.
What I thought on the topic is that the cause of resistance is 'the effective nuclear charge'. The nucleus holds the electrons with it's effective nuclear charge. Now if in a wire ,we bring potential difference across it's two points, then a electric force will be applied on the electrons of the wire. This force will try to take the electron away from the nucleus while the nucleus will try to keep it with itself. Thus the electron will not have as much acceleration as it should have had. Also as the electron detaches itself from one atom, it goes into the orbital of the consequent atom and the energy released from this(electron gain enthalpy) will cause any other electron to eject from the atom and move to the consequent atom and this goes on resulting in flow of electrons. Also the heating effect is caused because when the electron enters the orbital of an atom, maybe it's effective nuclear charge is strong enough to atleast keep some of the electrons and the electron gain enthalpy released from this will cause the heating. Also metals are good conductor because their effective nuclear charge on the electron in the outermost shell is not as strong as that exerted by a non metal and so allow flow of electrons easily.
This was what I thought on the topic. Please tell me if it is correct or not and if it is not correct, then what is the real cause of resistance and what is the flaw in my thinking.