Royal aide resigns following exchange with charity boss that was perceived as racist