They were better implemented in Sims 2/3. In Sims 4 they are random, usually their randomness is attatched to the latest Pack you installed, kidna trying to force you tu use all the new features added. In previous games they used to be related to your Sims life time wishes/aspirations and their traits, in SIms 2 some of the premades even have a set of intended wishes and fears that if followed could help to trigger the scripted events like Cassandra marrying Don Lothario and things like that.
I don't liek that they took time to add an toggle off option for the whims, not cuz i dont like toggles, i actually think the game should have more of them, but is sounds like they just dont want to work in improving the whims in the future, which sucks.