You will need:
1. Fill the pie plate with water, about 3cm in depth.
2. Float the styrofoam in the middle of the plate.
3. Carefully stroke the needle lengthways along the bar magnet, around 30 times.
4. Gently place the needle on the styrofoam and watch what happens.
The Earth is like one gigantic magnet, where nobody really knows how it works.
A good theory is that the magnetic field is generated by the movement of the molten iron in the Earth's mantle. Compasses are just smaller magnets that detect the North Pole of the Earth's magnetic field.
Rubbing the iron needle on the magnet aligns the magnetic domains within the needle,
making it magnetic. Floating it allows the magnetic needle to align with Earth's magnetic field.
This type of compass has been around for hundreds of years, ever since the properties of magnetite or 'lodestone' have been used for navigation. Lodestone literally means 'the stone that leads'.