I know the that it(Resonance) is the delocalisation of pi electrons but how and why are those electrons delocalised? What is the driving force that causes the effect?
Resonance is a conceptual tool to help make sense of the real observed structures of molecules
Resonance is not a real physical phenomenon. That is the first important thing to realise. It is merely a tool to bridge the simple view where all bonds consist of integral numbers of electrons and the real structures of molecules.
The simple view of bonds often fails to represent the "real" observed structure of molecules. The archetypal example is benzene. A simple view of the bonding of benzene has the molecule consisting of alternating single and double bonds (which might be called cyclohexatriene). This theoretical molecule has the bonds neatly grouped into simple bonds that use up all the available electrons into either single bonds (one pairs of electrons) and double bonds (two pairs of electrons). But this would imply that the bond lengths alternate. But we know the structure of benzene and the bond lengths are all the same. We can explain this with molecular orbital theory when we recognise that some of the bonds are delocalised, but that gets fairly sophisticated fairly quickly and chemists prefer easier ways to keep track of the electron counts when writing structures on paper and explaining reaction mechanisms.
One halfway house that saves the ability to write structures where simple electron counts are possible is the idea of "resonance". Instead of needing to invoke molecular orbital theory all the time we can write the structure of benzene as a combination of two structures where the double and single bonds alternate. We pretend that the real structure is a "resonance hybrid" of the two hypothetical structures. This is like the mathematical average of the two competing structures.
More complex molecules can also be represented as combinations of (more complex) resonance structures. We often say that the structure consists of resonance hybrids. But resonance is not a real physical phenomenon. The different structures are not real independent structures that rapidly interchange: they are merely a convenient model so chemists can talk about electron counts and draw structures without having to invoke much more complex bonding theories.
So there is no such thing as "resonance" as a physical phenomenon. What drives the structures of molecules is the way orbitals in atoms combine together in molecules and that is more complicated than simple views of bonding can represent. The underlying driving force is quantum mechanics and energy minimisation of the possible ways atomic orbitals interact in molecules. And that is sometimes far more complicated than simple views of bonding can easily represent.
Resonance rather than a physical process is our description of a molecule.
Basically we mixes different descriptions (limiting structures or canonical formulas in the frame of valence bonds theory, which is the one more reflecting the way we draw chemical structures using Lewis based notation).
We need such a mixed description all the time that a single canonical form turns out inadequate.
I just recall here the the mix, so-called hybrid of resonance, is the only one physically describing the molecule and is, thus, real. The canonical forms are just hypothetical structures for which properties can only be wisely reconstructed or computed, depending on the level of treatment.
Shall we adopt different and more advanced ways to arrive at the molecule bonds description, we would see that the orbitals describing certain electrons would be spread over part of the molecule, or even its whole.
It is in such a sense that the electrons of a resonance hybrids are delocalised.
For what are the forces driving this delocalisation one can answer by big principle, that is the system has lower energy in the way it is. For what physically keep electrons around the nuclei fixing them in that molecular structure, well this is electromagnetic in nature, with the constraints of quantum mechanics. This is independent from actual delocalisation (resonance) taking place or not.
There is no special force for having resonance. It just happens that under the given potential, the electrons have a minimum in energy when spread rather than being under the influence of just one or a couple of nuclei.
If you really wish a kind of "meccano" analysis of the reason, let us take the archetypal benzene although it will be a kind of chicken / egg discussion.
A common perception at school is that is the sextet of pi electrons that drove benzene in its shape. However, a more natural picture with both energetic and symmetry grounds, is that the sigma-bond skeleton rather opposes its deformation (how it would be for shrinking where the hypothetical double bonds must be localized and extending in between) and forces less bound pi-electrons to delocalise as a ring.
Finally I often heard that delocalisation is due to the Heisenberg principle. This is wrong. At least, it is true just in the sense that the above principle is general and forces us to treat electrons as spread particle for which only a wavefunction description is possible (the orbital, in atoms and molecules). In such a sense, of course, electrons are delocalised. But their are always so and is not the same (level of, or concept of) delocalisation which pairs with resonance.
In ethene, or in the hypothetical canonical form cyclohexatriene, the electrons are spread in orbitals. Still the pi-orbitals are localised in double bonds. In benzene, the electrons, that still obey the quantum rules, are in spread orbitals. Indeed, as we know, there are no double bonds. But the principle of indeterminacy is alway there, and so is even for the only electron of one hydrogen atom.
Why do electrons delocalise? Delocalising is a stabilizing force in a way such that when the electron has a greater number of orbitals to move into the energy spreads over a larger area than in a single orbital as the distribution of energy in multiple orbitals brings extra stability in the system.
There is also a possibility that after energy gets distributed there is a lowering down of the total internal energy of the molecule had there been a single orbital holding the energy ie. if there were no delocalisation.
Have a look at this one. Why does delocalization of π electrons bring stability?