Can someone clearly explain the tasks of each pin in a plug. Is there a difference between one phase and three phase plugs? Does the electricity enters our home from line connection and goes back to the generator from neutral connection? The third one is connected to ground to protect us but is it really necessary because some plugs only have two pins.
To power a device, current has to flow thru it. That means it has to go in one place and come out another, which requires two wires.
The third wire of most outlets is a safety ground. It is not necessary to power a device, but can be useful to some devices. Any device that has a conductive outer shell is a potential safety hazard. It would only take one fault to make the shell live, like the hot wire breaking or slipping off some mounting, then touching the inside of the case instead.
In general, we try to keep users two independent faults from danger. The above example of the hot wire coming off and touching the chassis is just a single fault. Now the chassis is at lethal voltage, and you don't even know this until you touch it and something grounded. Then its too late.
In such cases, the chassis is tied to the ground line. If the fault described above happens, hot is shorted to ground, which will cause a lot of current to flow and trip the breaker.
When the outer shell of a device is made of insulating material, the user can touch it no matter what went wrong inside. Such devices don't require a ground connection, and there's often no place to connect it anyway. Usually such devices are "double insulated". That means the hot voltages are normally insulated with insulation on the wire and the like. Nothing on the hot side is supposed to rub up against the case without a deliberate layer of insulation in between. Then you still have the case if that layer fails.
Another reason for the ground connection is to allow devices to reduce both conducted and radiated emissions. Most line filters are common mode chokes, also called baluns, with capacitors to ground on the line cord side of both AC lines. The balun increases the impedance of the unwanted signals, then the capacitors shunt the signals to ground. This isn't possible without a ground connection.
Figure 1. Supply transformer supply and earthed appliance.
Yes Live is the supply, Neutral is the return and the Earth is protection. Normally there is no current in the earth wire but if, for example, a live wire fell off inside the appliance and contacted the metal there is a risk of electrocution. Earthing the appliance prevents the case rising to dangerous voltages. In the event of a sever fault a high current may flow but the fuse will then blow, making the system safe.
Double insulated devices don't need to be earthed so a two-pin plug is adequate.
You're probably talking about the american plug style,so there will be two holes which look quite the same.One of them will be the HOT pin and the other the NEUTRAL,which closes the circuit,so through them is supplied AC to your appliances.The third one,whose hole looks like a mouth is the GROUND.This hole is connected to some metal rods or conductive objects(metal) which are buried into the ground.This helps protect you form electroshocks in case you plug in a device which has a metal surface and one of the supplying wires accidentally touches the metal case,turning you into a possible conductive path(in case you touch the metal surface).Now the GROUND pin will protect you,short-circuiting the metal case,drawing all the current so you won't be able to.You should be able to notice the difference between 2 pin plugs and 3 pin plugs.It's just that the 2 pin plugs don't have the GROUND pin,so you should be careful if you connect something with some exposed metal surface.The rest is the same.Note that the european socket's holes look different.The supply pins have each a round hole and the GROUND connects to your appliance through two copper metal strips:https://en.wikipedia.org/wiki/Schuko.
Can someone clearly explain the tasks of each pin in a plug?
Assuming you mean a standard plug-it-into-the-wall-in-Canada-and-the-USA plug: the large flat opening on the left is the neutral. It carries current but does not supply voltage. The one on the right is the hot; it supplies voltage. The roundish one at the bottom is safety ground. It carries current never, unless there is an electrical fault. It's there for cases where something has failed.
Is there a difference between one phase and three phase plugs?
Yes. It would be disastrous if a plug expecting neutral and safety on two of the pins found voltage. This would be asking for an electrical fire. Plugs are designed better than that.
Does the electricity enters our home from line connection and goes back to the generator from neutral connection?
No. The neutral goes to a metal rod hammered into the ground. You can think of this as sending current back to the utility through the ground if you like.
The third one is connected to ground to protect us but is it really necessary because some plugs only have two pins.
You ask if it is necessary. This is vague. Is a safety ground necessary for the correct operation of the device? Typically no. There are some devices which require a solid connection to ground, but most do not. Is it necessary by standard engineering practices to provide safety grounds for some devices? Absolutely yes.