Glass containers were far more common when I was growing up. Manufacturers and retailers prefer plastic because it's cheaper to ship and has less breakage. At the consumer end of things, glass is a minor danger but I remember when sidewalks and parking lots used to frequently have glass shards. Nearby grassy areas ended up with them too. And if you dropped a glass jar at home, it was a challenge to find every little bit of glass that flew off across the floor.
Plastic has done away with many of the problems that glass containers created, though it has a ton of issues of its own.