Igm is always the first antibody
your body produces in response to an infection.
After awhile, your body "switches" to making igg for long-term immunity. Once it starts making igg, it slows down in producing igm, and eventually stops making it. So if you have igm, it means you have had the infection, and you acquired it relatively recently. If you only have igg, it means you had it longer ago.