This superstition comes from the idea that many early cultures considered a triangle to be a sacred symbol of life.
For Christians, a triangle represents the Holy Trinity.
A ladder against a wall forms a triangle with the ground, and so to walk beneath it would be to disrupt a sanctified space and risk divine wrath.
Even earlier, Christians considered the ladder resting against a wall to represent the ladder that rested against the cross during the Crucifixion, and therefore evil.
For this reason condemned criminals were forced to walk under the gallows ladder, the entrance way to eternal darkness.
The executioner always walked around it to position the noose.