Halloween comes from the phrase "All Hallows Eve" but I will explain more on that later. First, the word "Hallowed" is an English word used in a common Christian prayer called "The Lord's Prayer", and it is found in a line that goes: "Hallowed be thy name". This line actually means "may (or let) your name be holy". In short, the word "holy" in English, can be a synonym for "Hallowed".
In some Christian traditions, November 2nd is "All Souls Day" and November 1st is "All Saints Day". Both days are purposely back to back and have been celebrated for thousands of years all over the world. On All Souls Day, all those who have died are honored. On All Saints Day, all souls in heaven are honored. So in essence, Halloween became the eve of the day to remember those who have passed-on. To give you an example, this is just like how Christmas Eve is the eve of Christmas. Put together "hallowed" and "eve" and you get "All Hallows Eve" now commonly known as Halloween.
So why the costumes? Because both All Souls & All Saints Days are said to remind the community that the living and the dead are united which can be a universal understanding in many areas of faith. The idea is that death might seem scary and goulish however, the hope of heaven and the victory against death is, in a small way, thumbing your nose at death while remembering those you have lost. To honor these souls you would dress up like them in costume.
In a similar way, Mexican culture has another angle on remembering those passed, with Dia de los Muertos. This holiday enjoys celebrating and demonstrating respect for loved ones passed; making death a bright, colorful, and cheerful experience (as featured in the Disney film "Coco").
Today, Halloween has become a night of fun for children with costumes that are both beautiful and scary. It is a great night of tradition for many children across the world and like with all celebrations, adding candy to the scene makes every holiday so much sweeter.