I was wondering what could cause me to get random bruises on my body? I get them on my legs sometimes and had it once in my back but it went away. Why

Need to examine. It is not feasible to provide a meaningful opinion without taking additional history, physical examination and may be some tests. It would be prudent to see your doctor, if the symptoms persist. The likely causes include unrecognized trauma, side effect of some medication you may on, platelet function disorder or other coagulation abnormality, steroid excess, insect bites and so on.
For good health - Have a diet rich in fresh vegetables, fruits, whole grains, milk and milk products, nuts, beans, legumes, lentils and small amounts of lean meats. Avoid saturated fats. Drink enough water daily, so that your urine is mostly colorless. Exercise at least 150 minutes/week and increase the intensity of exercise gradually. Do not use tobacco, alcohol, weed or street drugs in any form.
Practice safe sex, if you have sex.