- The Egg is handed to you by Riley on Iron Island.
- Hatch it to get Riolu.
- This happens around the late midgame, though what counts as the middle of the game is a matter of opinion.
Trading may let you get one sooner, but this answer covers the no-trade route.