The concrete meanings are that on applies to two-dimensional surfaces and in applies to 3-dimensional containers. Metaphorical uses of the two prepositions usually conceptually follow these guidelines... but not necessarily.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.