Basically with this kind of thing we obviously do not know the exact origin of the joke but we do know where it was first printed. The joke is actually only around 150 years old it was first printed in a magazine called the Knickerbocker where it was told as follows.
There are ‘quips and quillets’ which seem actual conundrums, but yet are none. Of such is this: ‘Why does a chicken cross the street?[’] Are you ‘out of town?’ Do you ‘give it up?’ Well, then: ‘Because it wants to get on the other side!’
Now as for its popularity I would say there are two reasons why. The first is that it is basically a anti joke which plays with our normal expectations of what a joke is. To give an idea the chicken joke also had another version some 50 years latter that in no way is popular yet is actually more of a joke. That version was.
Why shouldn't a chicken cross the road? Because it would be a fowl proceeding.
Now as you can see as a joke technically it is better, it has wordplay and a fairly good pun yet the anti joke is by far the more popular.
As for a second reason it also works on the level of the lightbulb joke where you can make countless variants which keeps the joke somewhat fresh.