I have a room in my apartment that can sometimes get around 40°F (4°C), and that's where my new tankless water heater is installed. Should I take any special precautions to keep my pipes from freezing or to avoid any other weird problems with my water heater? I live in the US Midwest in a second-floor apartment.
40°F is above freezing, so freezing shouldn't be a problem.
If the weather is getting cold and you're concerned that this utility room might dip below the freezing point, prop the door open a bit to allow some heated air in.
Also, since this is an apartment, talk to your landlord about your freezing concerns and ask him to address the issue - maybe adding some insulation to all the pipes in this room, or, even better, adding heat to the room!
Additionally, based on reading the comments on the OP, talk to the landlord about your freezing concerns and ask him if this is something for you to worry about at all. It may be that she's fully aware of the temperature issues and purchased heaters that have an anti-freeze feature built right in so this won't be a concern at all. It's still possible for piping to freeze, but again, 40°F is above the freezing point and it's unlikely to be a concern unless a serious cold spell hits and gets this unheated room really cold. Simply opening the interior door to this room should allow more than enough heat from the rest of the apartment into the room to keep it above freezing.