Why does the seed of the coconut tree have a liquid in it?
It is a transitory state. 

During coconut development the "milk" actually starts as a spongy solid a multinucleate endosperm. As the coconut develops it absorbs this tissue. Because of a coconuts hard structure this leaves a cavity since the coconut cannot change shape as the tissue density changes, some fluids including oils are left behind as hte tissue is broken down and reabsorbed. But this fluid will be reabsorbed as the the developing cotyledon fills in the cavity. The fluid is a by product of the cavity but the the cavity is needed due to the unusual development of the coconut.  

As a side note most comercial coconut milk is actually squeezed out of the solid endosperm.