When are we supposed to give machtzis Hashekel exactly and Why is the custom to give machtzis hashekel before Purim?
It is given on Taanis Esther before Mincha. The reason we give it, is to recall the half-shekel that was donated annually to the Temple treasury in the month of Adar.
Rama says to give it before the mincha before Purim (he quotes that from the Minhagim and says that that's the accepted practice). Mishna B'rura then cites Magen Avraham as having said that the custom where and when he was was to give it at shacharis, before reading the m'gila, on Purim. Mishna B'rura then concludes (citing P'ri M'gadim) that the common practice now (or when he wrote, a century or so ago) is to give it before mincha [before Purim]. (This is all in 694:1.) As always, CYLOR for a practical ruling.