It used to be so simple: To get from one level to another all that was required was to walk from right to left and get to the stage's exit. When games switched over to 3D however developers wanted to give players an oppertunity to better explore the worlds around them thus the "collectibles that unlock worlds" was born.
Super Mario 64 is the game that really set the groundwork for this, in the game players took on certain tasks within each level in order to obtain Power Stars. Once Mario collected enough power stars he could then enter any world so long as he had enough stars to unlock it. Pretty soon several more N64 games were released that copied this basic concept, and then developers for other systems began to take notice and it became a trend. The concept was so prevalent that between the years 1997 and 2001 it was hard to find a 3D platformer that didn't use this concept.