The Shach (7) to Yore Dea 87:4 says clearly there is no marit haayin when there is a evident possibility that you are doing something permitted, for example cooking for the sick. This is based on the Shach when describing cooking non-kosher milk with meat:
בבישול לחודיה ליכא משום מראית העין, דהא יכול להיות שמבשל לצורך רפואה או שאר דברים
The cooking of it (non kosher milk with meat or chicken with almond milk) is not prohibited because of marit haayin (that you might eat it), since it is possible that one is cooking (as opposed to eating where the Shach is quoted above that there is marit haayin to eat chicken with almond milk) (the mixture) for the need of healing (someone in danger) or for other purposes (e.g. selling to a gentile) (but when a healthy person eats chicken with almond milk there is no alternative but to think he is sinning).
When so many people cannot fast for health reasons, it is not feasible to close restaurants and bakeries at the expense of those, who cannot make their own meals, but need to break their fast. In every city I have been to on fast days batei dinim allow restaurants to remain open and those who fast know not to eat.