When cars were introduced, crossing city streets became a lot more hazardous than when horse-drawn carriages were the only traffic.
New safety laws were introduced, and anyone ignoring them was considered a country bumpkin.
In the early part of the twentieth century, unsophisticated rural people were often referred to as “jays,” as in just another bird from the country.
And so their ignorance about how to properly cross a street became known as jaywalking.