According to my research just now, they were initially included as a bonus to another product, like gum or cigarettes! Presumably you didn't know which ones you were going to get and had to trade around if you wanted a complete collection. According to this source [0], the trend switched from cigarettes to gum after it became illegal to sell cigarettes to children.
I think the scarcity that led to certain cards becoming more valuable was incidental rather than intentional, but I'm not an expert.
[0] https://www.amerlegends.com/the-history-of-marketing-basebal.... [1] https://en.wikipedia.org/wiki/Baseball_card