I mean I'm pretty sure a lot of it comes from things like that, I also notice quite often the positive things are male while the negative opposite is female: le beau temps/le soleil, la pluie ; le plaisir, la douleur ; le jour, la nuit; etc etc.
Edit: not sure why this comment is getting downvoted, do you think I'm saying it's a good thing the language was built on sexist principles? Here's an article that talks about how it wasn't always like that and there was a campaign in the 17th century to masculinize the language, making the masculine the "noble" gender in grammatical rules. It's not far fetched to think similar principles applied to gendering random things.
It's not a coincidence, it's systemic sexism. If you use sexism as your guiding principle when if comes to generated nouns, in almost every language that has them, you'll be right most of the time.