Fasting also has a moral. Some people around the world don't have a bite to eat sometimes or even clean water to drink. Fasting gives us a taste of how they feel about it. This teaches us to be kind and caring to those in need. Living the sorrows of others helps, you know. By the end of the month, there is an obligatory tax or charity, one part of the zakat or alms, to be given to the poor not the government, a small token only for the capable to do. This is another point showing how Islam cares for those in need.
Not sure why Mondays and Thursdays are encouraged to fast, but I heard that in those days, deeds of people go up to God, so fasting in such days could be to have a pure spirit while it is done. I think it is kinda going to meet a very important person to report something important that you need to have a clear mind to do it best.
What voids fasting are eating, drinking and sexual intercourse. Other bad deeds hurt fasting and give it less credit. Kinda like having things done right is a good thing, but not doing so, does not void it. It also encourages/trains us to stop doing bad deeds in other non fasting days.