The octet rule states that an outer shell with eight valence electrons is complete, any less than eight is not fully complete and the element with bond with other elements in order to complete the outer shell. Since magnesium has two valence electrons and oxygen has six, they will bond together for form a complete shell of eight valence electrons.
*Bonus* Q: How many tickles does it take to make an octopus laugh?
A: Tentacles.
I hope you got a good grad on your assignment! ^w^