Eggs do contain some amounts of magnesium but other foods such as dark chocolate, Nuts, Avocados, Tofu, Legumes, whole grain foods and seeds are the best for magnesium intake.
So yes eggs can help you when you have a magnesium deficiency but eating other foods such as listed above can help you get more nutrition and magnesium than just eating eggs.
You can also take a magnesium supplement to boost your magnesium intake.