How did this originate?
The custom of Halloween is traced to the Druid festival of the dead.
At that time the Roman Pantheon was built by Emperor Hadrian in 100 A.D. as a temple to the goddess Cybele and other Roman deities.
It became the principle place of worship.
Roman pagans prayed for the dead.