Foolish is an adjective (the noun being 'fool') and stupid may be used as an adjective or a noun. They are both similar, but stupid is a more comical, everyday used word that could be used jokingly with friends or as an insult. Foolish, being as it is more rarely used in everyday conversation, is more rude or serious when actually used (but it may be used jokingly as well of course)
Ex: Foolish:
1) That was very foolish of the student to think he didn't need to prepare for the exam yesterday.
Ex: Stupid:
1) I am so stupid. I left my keys in the car again.
2) Stupid, come here and help me with this problem you caused.
I really hope I helped