What causes loss of appetite and insomnia?

Multiple things. The most common cause of combined loss of appetite and insomnia, would be depression. You could start with your primary care physician for an evaluation -- and depending on what all is going on with you, s/he may also want you to see a psychiatrist and/or sleep specialist. If depression is diagnosed, there are helpful treatments with both psychotherapy and medications. Many reasons for hope!