Even though the the peloton is riding at a very steady speed, the distance between riders is constantly changing. There might not be much distance between riders from side to side, but slight changes in speed open up small gaps between riders. Through these gaps you can squeeze your way up through a tight bunch to make your way closer to the front.
Consistency and predictability are two keys to moving through a tight pack. You don’t want to make the riders around you nervous by manking any sudden or sketchy moves. Riding steadily and decisively also leaves no doubt about where you’re going. That means the riders around you can act accordingly. Many crashes in the peloton happen because one rider moves and the rider behind him either didn’t expect it or didn’t know where that first rider was going.
Be careful not to move through a gap too aggressively. If you stomp on the pedals to move up one space you’ll end up hitting the brakes. This has a ripple effect behind you and makes it more difficult for those riders to stay at a consistent pace. It takes some practice to get it down, but once you figure out just how much power you need to move up without having to tap your brakes, you’ll be able to cruise up through the field without anyone even noticing it. Also see this post for a quick tip on how to let other riders know you’re coming through.
Getting through a tight pack in the middle of a race is one thing but working your way to the front of a charging train of sprinters is another. Watch out for the "swarms " passing you on your left or right sides and jump in on them. Sprinters have great peripheral awareness and either see or sense riders coming up on their sides. This helps them decide whether to go left or right around the wheel ahead of them, but a lot is also up to a combination of luck and experience.