There's an infinite number of ways to end up at this feeling+realization.
Personally, I reached this when I got interested in cosmology (PBS Space Time!!).
I invoke Nihilistic (existential nihilism) ideas. Because it's not hard to end up at the conclusion that everything is meaningless - you create your own meaning.
I recognize lots of problems attempting to apply this at scale, but it works for me personally.