It is not illegal to drink coffee or water while you are driving, but you could end up being charged with some other form of distracted driving if you don't follow Canada's road rules. Furthermore, if you end up in an accident, you might have to deal with the fallout from that. If you don't feel you can safely drink coffee while driving, avoid it altogether.