I thought Halloween started in Ireland when the poor would go to the door of the wealthy and ask for apples or nuts?
Not really, it dates back to Samhain on the Irish calendar, which was essentially the day that the shepherds returned with the flocks from their summer pastures. In some ways, it's a lot like Mothering Sunday in that origin of families being reunited, so it was decidedly a family holiday. It was also the time of year when the flocks and herds were culled, since you wouldn't keep any but the breeding animals alive over the winter. It meant there was plenty of meat around for once, so you bet there was feasting.
Aside from the culling, the ghostly aspect of Samhain/Halloween came into it when people figured that on this night of homecoming, even the dead would visit as they were wont to do in life. So they opted to be hospitable and leave out some of the feast for them. Of course, there are a huge range of folk beliefs, so a hundred different reasonings for the customs would be equally true in different places. Jack-o-lanterns have been said to be everything from lighting the way home for the beloved dead to warding away "the good neighbors" and unpleasant sorts. Masks have been said to be worn because this time of year everything is in flux, so "the other side" could be showing up (both good and bad), or because you didn't want to be recognized by the dead, for whatever reason.
Trick or treating is actually a recent phenomenon, it was thought up in the early 20th century because prior to that there was a lot more "mischief night" than friendly Halloween as we know it going on. The idea was to do something child-friendly and entertaining, most of the ancient origins of trick or treating were frankly made up at that time (this is around the same period that gave us the George Washington and the cherry tree story).
Since I'm getting into it, I'd also point out that Halloween isn't actually a one day thing. There's Halloween, All Saints' Day and All Souls' Day, in succession, with folklore and traditions associated with each one. Of course, back in history, there probably wasn't a set calendar day for any of it, it was just when it got too cold to stay out in the summer pastures, and it would continue so long as the party mood did.
(Would also care to point out, that as far as I know, for the entire historic period of Ireland from which we have records, including of their calendar: they were Christian. Ireland retained Christianity when the rest of the British Isles "lost it" for a period, and was part of the direction from which the British Isles were re-missionized. That would mean that Samhain/Halloween, from the Irish calendar, was not considered Pagan from the period that we have records, and we frankly don't have any real evidence of a great Pagan Samhain from beforehand... because there were no pre-Christian records to speak of. And, speaking as a Pagan, I can't quite see how a harvest or a homecoming is strictly one religion or another.)