Let's assume that the chemical reaction will progress as written.

Balancing ionic equations can be quite easy AS LONG AS YOU MEMORIZE YOUR CATIONS AND ANIONS. There are a number of ways to do this, so you have to find a way that actually works for you. For now, let's do a tally sheet of all ions involved.

#Mg(NO_3)_2# + #K_3PO_4# #rarr# #Mg_3(PO_4)_2# + #KNO_3#

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2

#K^(1+)# = 3

#PO_4^(-3)# = 1

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1

#K^(1+)# = 1

#PO_4^(-3)# = 2

Let's balance the most complicated ion first: the #PO_4^(3-)#.

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2

#K^(1+)# = 3

#PO_4^(-3)# = 1 x #color(red)2# = **2**

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1

#K^(1+)# = 1

#PO_4^(-3)# = **2**

Since the #PO_4^(3-)# ion is bonded to the #K^(1+)# ion, you need to multiply it by 2 as well.

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2

#K^(1+)# = 3 x #color(red)2# = **6**

#PO_4^(-3)# = 1 x #color(red)2# = **2**

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1

#K^(1+)# = 1

#PO_4^(-3)# = **2**

#Mg(NO_3)_2# + #color(red)2K_3PO_4# #rarr# #Mg_3(PO_4)_2# + #KNO_3#

Now notice that this move have created an imbalance in your #K^(1+)# ion with 6 ions on the left as opposed to only one ion on the right. To compensate, we have:

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2

#K^(1+)# = 3 x 2 = **6**

#PO_4^(-3)# = 1 x 2 = **2**

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1

#K^(1+)# = 1 x #color(blue)6# = **6**

#PO_4^(-3)# = **2**

Again, since the #K^(1+)# ion is bonded to the #NO_3^(-1)#, we need to also multiply it by 6.

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2

#K^(1+)# = 3 x 2 = **6**

#PO_4^(-3)# = 1 x 2 = **2**

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1 x #color(blue)6# = **6**

#K^(1+)# = 1 x #color(blue)6# = **6**

#PO_4^(-3)# = **2**

#Mg(NO_3)_2# + #color(red)2K_3PO_4# #rarr# #Mg_3(PO_4)_2# + #color(blue)6KNO_3#

Now your #NO_3^(-1)# ion is unbalanced with only 2 ions on the left as opposed to the 6 on the right. Thus,

Left side:

#Mg^(2+)# = 1

#NO_3^(-1)# = 2 x #color(green)3# = **6**

#K^(1+)# = 3 x 2 = **6**

#PO_4^(-3)# = 1 x 2 = **2**

Right side:

#Mg^(2+)# = 3

#NO_3^(-1)# = 1 x 6 = **6**

#K^(1+)# = 1 x 6 = **6**

#PO_4^(-3)# = **2**

Same as above the #NO_3^(-1)# ion is bonded with your #Mg^(2+)#. Therefore,

Left side:

#Mg^(2+)# = 1 x #color(green)3# ==**3**

#NO_3^(-1)# = 2 x #color(green)3# = **6**

#K^(1+)# = 3 x 2 = **6**

#PO_4^(-3)# = 1 x 2 = **2**

Right side:

#Mg^(2+)# = **3**

#NO_3^(-1)# = 1 x 6 = **6**

#K^(1+)# = 1 x 6 = **6**

#PO_4^(-3)# = **2**

Final Answer:

#color(green)3Mg(NO_3)_2# + #color(red)2K_3PO_4# #rarr# #Mg_3(PO_4)_2# + #color(blue)6KNO_3# (balanced)